Skip to content

Commit 8ced840

Browse files
authored
integrate fix-vendor-hash into ci.yml so we don't get redundant builds (#153)
## What this changes unify CI actions for fixing nix hash and building docker image ## How I tested this built locally using nix ## Checklist - [x] I have read [CONTRIBUTING.md](../CONTRIBUTING.md) and this PR follows the guidelines - [x] A human has reviewed the **entire diff** of this PR, every line of code - [x] A human understands the changes and can explain why this approach is correct - [x] Tests pass (`make full`) - [x] This PR doesn't have AI-generated boilerplate or co-author lines - [ ] This PR was authored and submitted by an AI agent without human review
2 parents 43d9e40 + 8d21163 commit 8ced840

2 files changed

Lines changed: 38 additions & 59 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,51 @@ jobs:
7272

7373
docker:
7474
runs-on: ubuntu-latest
75+
permissions:
76+
contents: write
7577
steps:
7678
- uses: actions/checkout@v6
79+
with:
80+
ref: ${{ github.head_ref || github.ref }}
7781

7882
- name: Install Nix
7983
uses: cachix/install-nix-action@v31
8084
with:
8185
nix_path: nixpkgs=channel:nixos-25.11
8286

83-
- name: Build Docker images (amd64 + arm64)
87+
- name: Build Docker images (fix Nix hashes if needed)
8488
run: |
85-
nix build .#docker -o result-amd64
89+
# Build amd64, auto-fixing hash mismatches (up to 3 rounds for
90+
# npmDeps + vendorHash + verify)
91+
for attempt in 1 2 3; do
92+
echo "=== Build attempt $attempt ==="
93+
if nix build .#docker -o result-amd64 2>build-err.log; then
94+
break
95+
fi
96+
97+
cat build-err.log >&2
98+
NEW_HASH=$(grep -oE 'got:[[:space:]]+[^ ]+' build-err.log | sed 's/got:[[:space:]]*//')
99+
if [ -z "$NEW_HASH" ]; then
100+
echo "Build failed without a hash mismatch"
101+
exit 1
102+
fi
103+
104+
if grep -q 'npm-deps' build-err.log; then
105+
echo "Fixing npmDeps hash: $NEW_HASH"
106+
sed -i "/fetchNpmDeps/,/};/ s|hash = \".*\"|hash = \"$NEW_HASH\"|" flake.nix
107+
else
108+
echo "Fixing vendorHash: $NEW_HASH"
109+
sed -i "s|vendorHash = \".*\"|vendorHash = \"$NEW_HASH\"|" flake.nix
110+
fi
111+
done
112+
86113
nix build .#docker-arm64 -o result-arm64
114+
115+
- name: Commit hash fix
116+
run: |
117+
git diff --quiet flake.nix && exit 0
118+
git config user.name "github-actions[bot]"
119+
git config user.email "github-actions[bot]@users.noreply.github.com"
120+
git add flake.nix
121+
git commit -m "fix: update Nix hashes for dependency changes"
122+
git push

.github/workflows/fix-vendor-hash.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)