Skip to content

Commit f517f8c

Browse files
committed
ci(gh-actions): Rename reusable workflows to .github/workflows/reusable-* and call them with relative path
1 parent dfdd93f commit f517f8c

File tree

5 files changed

+77
-68
lines changed

5 files changed

+77
-68
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717

1818
jobs:
1919
ci:
20-
uses: metacraft-labs/nixos-modules/.github/workflows/flake-checks-ci-matrix.yml@main
20+
uses: ./.github/workflows/reusable-flake-checks-ci-matrix.yml
2121
secrets: inherit
2222
with:
2323
runner: '["self-hosted", "Linux", "x86-64-v2"]'
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "Update Nix Flake lockfile"
2+
3+
on:
4+
# Allow this workflow to be reused by other workflows:
5+
workflow_call:
6+
inputs:
7+
runner:
8+
description: 'JSON-encoded list of runner labels'
9+
default: '["self-hosted"]'
10+
required: false
11+
type: string
12+
13+
secrets:
14+
NIX_GITHUB_TOKEN:
15+
description: GitHub token to add as access-token in nix.conf
16+
required: false
17+
CACHIX_AUTH_TOKEN:
18+
description: 'Cachix auth token'
19+
required: true
20+
CREATE_PR_APP_ID:
21+
description: ID of the GitHub App used for opening pull requests.
22+
required: true
23+
CREATE_PR_APP_PRIVATE_KEY:
24+
description: Private key of the GitHub App used for opening pull requests.
25+
required: true
26+
27+
jobs:
28+
main:
29+
runs-on: ${{ fromJSON(inputs.runner) }}
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install Nix
35+
uses: metacraft-labs/nixos-modules/.github/install-nix@main
36+
with:
37+
nix-github-token: ${{ secrets.NIX_GITHUB_TOKEN }}
38+
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
39+
cachix-cache: ${{ vars.CACHIX_CACHE }}
40+
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
41+
substituters: ${{ vars.SUBSTITUTERS }}
42+
43+
- name: Run `nix flake update`
44+
id: update-lockfile
45+
run: |
46+
curl -fsSL --proto '=https' --tlsv1.2 \
47+
https://raw.githubusercontent.com/metacraft-labs/nixos-modules/main/scripts/commit_flake_update.bash \
48+
-o commit_flake_update.bash
49+
bash commit_flake_update.bash
50+
51+
- uses: tibdex/[email protected]
52+
id: generate-token
53+
with:
54+
app_id: ${{ secrets.CREATE_PR_APP_ID }}
55+
private_key: ${{ secrets.CREATE_PR_APP_PRIVATE_KEY }}
56+
57+
- name: Create Pull Request
58+
if: ${{ hashFiles('commit_msg_body.txt') != '' }}
59+
uses: peter-evans/create-pull-request@v7
60+
with:
61+
token: ${{ steps.generate-token.outputs.token }}
62+
title: 'Update Nix Flake lockfile'
63+
body-path: commit_msg_body.txt
64+
branch: 'create-pull-request/update-flake-lockfile'
65+
delete-branch: true
66+
branch-suffix: timestamp
67+
add-paths: flake.lock

.github/workflows/update-flake-packages.yml renamed to .github/workflows/reusable-update-flake-packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
runner:
88
description: 'JSON-encoded list of runner labels'
99
default: '["self-hosted"]'
10-
required: true
10+
required: false
1111
type: string
1212

1313
secrets:
Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,16 @@
1-
name: "Update Nix Flake lockfile"
1+
name: Update Nix Flake lockfile
22

33
on:
4-
# Allow this workflow to be reused by other workflows:
5-
workflow_call:
6-
inputs:
7-
runner:
8-
description: 'JSON-encoded list of runner labels'
9-
default: '["self-hosted"]'
10-
required: true
11-
type: string
12-
13-
secrets:
14-
NIX_GITHUB_TOKEN:
15-
description: GitHub token to add as access-token in nix.conf
16-
required: false
17-
CACHIX_AUTH_TOKEN:
18-
description: 'Cachix auth token'
19-
required: true
20-
CREATE_PR_APP_ID:
21-
description: ID of the GitHub App used for opening pull requests.
22-
required: true
23-
CREATE_PR_APP_PRIVATE_KEY:
24-
description: Private key of the GitHub App used for opening pull requests.
25-
required: true
26-
27-
# Allow this workflow to be triggered manually:
4+
# Enable option to manually run the action:
285
workflow_dispatch:
296

307
# Run every Sunday at 00:00:
318
schedule:
32-
- cron: 0 0 * * 0 # https://crontab.guru/#0_0_*_*_0
9+
- cron: 0 0 * * 0
3310

3411
jobs:
35-
main:
36-
runs-on: ${{ fromJSON(inputs.runner) }}
37-
38-
steps:
39-
- uses: actions/checkout@v4
40-
41-
- name: Install Nix
42-
uses: metacraft-labs/nixos-modules/.github/install-nix@main
43-
with:
44-
nix-github-token: ${{ secrets.NIX_GITHUB_TOKEN }}
45-
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
46-
cachix-cache: ${{ vars.CACHIX_CACHE }}
47-
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
48-
substituters: ${{ vars.SUBSTITUTERS }}
49-
50-
- name: Run `nix flake update`
51-
id: update-lockfile
52-
run: |
53-
curl -fsSL --proto '=https' --tlsv1.2 \
54-
https://raw.githubusercontent.com/metacraft-labs/nixos-modules/main/scripts/commit_flake_update.bash \
55-
-o commit_flake_update.bash
56-
bash commit_flake_update.bash
57-
58-
- uses: tibdex/[email protected]
59-
id: generate-token
60-
with:
61-
app_id: ${{ secrets.CREATE_PR_APP_ID }}
62-
private_key: ${{ secrets.CREATE_PR_APP_PRIVATE_KEY }}
63-
64-
- name: Create Pull Request
65-
if: ${{ hashFiles('commit_msg_body.txt') != '' }}
66-
uses: peter-evans/create-pull-request@v7
67-
with:
68-
token: ${{ steps.generate-token.outputs.token }}
69-
title: 'Update Nix Flake lockfile'
70-
body-path: commit_msg_body.txt
71-
branch: 'create-pull-request/update-flake-lockfile'
72-
delete-branch: true
73-
branch-suffix: timestamp
74-
add-paths: flake.lock
12+
update-flake-lock:
13+
uses: ./.github/workflows/reusable-update-flake-lock.yml
14+
secrets: inherit
15+
with:
16+
runner: '["self-hosted", "Linux", "x86-64-v2"]'

0 commit comments

Comments
 (0)