Update .github/workflows/nix.yml: pin to the current commit #296
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nix build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- uses: DeterminateSystems/nix-installer-action@aacc1657a206483a9d7037b91370e00407cf3ec5 | |
with: | |
determinate: true | |
- name: Run build | |
run: nix build | |
- name: Fix hash mismatches | |
if: failure() && github.event_name == 'pull_request' | |
id: fix-hashes | |
run: | | |
git stash --include-untracked | |
git fetch --depth=1 origin "$GITHUB_HEAD_REF" | |
git checkout -B "$GITHUB_HEAD_REF" "${{ github.event.pull_request.head.sha }}" | |
determinate-nixd fix hashes --auto-apply | |
if ! git diff --quiet; then | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add --update --ignore-removal . | |
git commit -m "[dependabot skip] Automatically fix Nix hashes" | |
git push origin "$GITHUB_HEAD_REF" | |
fi | |
git checkout - | |
git stash pop || true |