Skip to content

Commit 0d61e96

Browse files
committed
ci: auto-update nix hashes on PRs
1 parent 1c02a4e commit 0d61e96

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/nix.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,39 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: read
13+
contents: write
1114
steps:
1215
- uses: actions/checkout@v6
1316

17+
- uses: DeterminateSystems/determinate-nix-action@v3
18+
19+
- uses: DeterminateSystems/flakehub-cache-action@main
20+
1421
- name: Install Nix
1522
uses: cachix/install-nix-action@v31
1623

24+
- name: Fix hash mismatches
25+
if: failure() && github.event_name == 'pull_request'
26+
id: fix-hashes
27+
run: |
28+
git stash --include-untracked
29+
git fetch --depth=1 origin "$GITHUB_HEAD_REF"
30+
git checkout -B "$GITHUB_HEAD_REF" "${{ github.event.pull_request.head.sha }}"
31+
32+
determinate-nixd fix hashes --auto-apply
33+
34+
if ! git diff --quiet; then
35+
git config user.name "github-actions[bot]"
36+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
37+
git add --update --ignore-removal .
38+
git commit -m "[dependabot skip] Automatically fix Nix hashes"
39+
git push origin "$GITHUB_HEAD_REF"
40+
fi
41+
42+
git checkout -
43+
git stash pop || true
44+
1745
- name: Build package
1846
run: nix build -f default.nix

0 commit comments

Comments
 (0)