Skip to content

Commit 120e275

Browse files
committed
ci(vendor-hash): restore real hash before unchanged-check early-return
The workflow replaces vendorHash with a fake sentinel before calling nix build, parses the real hash from the "got:" line, and substitutes it back. When old_hash equals new_hash, the early-return branch was exiting before performing that final substitution, leaving the fake hash in nix/package.nix. Combined with go.mod/go.sum changes from go mod tidy, the Commit and push step then committed the fake hash. See PR #974 for a concrete occurrence. Move the restoration sed ahead of the unchanged check so the file is always in a valid state before any exit. Also pipe grep through head -n1 to defend against multi-line output (e.g. multiple FOD failures reporting their own got: lines).
1 parent f3ff269 commit 120e275

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,25 @@ jobs:
102102
sed -i "s|vendorHash = \"sha256-[^\"]*\";|vendorHash = \"$fake_hash\";|" nix/package.nix
103103
104104
output=$(nix build '.#micasa' 2>&1 || true)
105-
new_hash=$(echo "$output" | grep -oP 'got:\s+\Ksha256-[A-Za-z0-9+/=]+' || true)
105+
new_hash=$(echo "$output" | grep -oP 'got:\s+\Ksha256-[A-Za-z0-9+/=]+' | head -n1 || true)
106106
107107
if [ -z "$new_hash" ]; then
108108
echo "::error::Failed to extract vendorHash from nix build output"
109109
echo "$output"
110110
exit 1
111111
fi
112112
113+
# Restore a real hash before any early-return so the fake hash can
114+
# never reach a commit. If old_hash == new_hash this substitutes the
115+
# original value back in place of the fake.
116+
sed -i "s|vendorHash = \"$fake_hash\";|vendorHash = \"$new_hash\";|" nix/package.nix
117+
113118
if [ "$old_hash" = "$new_hash" ]; then
114119
echo "vendorHash unchanged ($old_hash), nothing to do"
115120
echo "changed=false" >> "$GITHUB_OUTPUT"
116121
exit 0
117122
fi
118123
119-
sed -i "s|vendorHash = \"$fake_hash\";|vendorHash = \"$new_hash\";|" nix/package.nix
120124
echo "changed=true" >> "$GITHUB_OUTPUT"
121125
122126
- name: Verify build

0 commit comments

Comments
 (0)