name: Fix flake hashes on: workflow_dispatch: push: branches: [dev] paths: ['pnpm-lock.yaml'] jobs: fix: name: Fix flake hashes runs-on: ubuntu-latest permissions: id-token: write contents: write steps: - name: Generate bot token id: app-token uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 with: app-id: ${{ secrets.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} permission-contents: write - name: Checkout dev uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: dev persist-credentials: true token: ${{ steps.app-token.outputs.token }} - name: Install Determinate Nix uses: DeterminateSystems/determinate-nix-action@527f17dd63d2d60d3e5552934bc84b9a33a14d11 # v3.22.2 - id: check run: nix flake check -L --keep-going continue-on-error: true - name: Fix hash mismatches if: steps.check.outcome == 'failure' run: determinate-nixd fix hashes --auto-apply - name: Get GitHub App User ID id: get-user-id run: echo "user-id=$(gh api "/users/${STEPS_APP_TOKEN_OUTPUTS_APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" env: GH_TOKEN: ${{ steps.app-token.outputs.token }} STEPS_APP_TOKEN_OUTPUTS_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} - name: Configure bot git identity run: | git config --global user.name "${STEPS_APP_TOKEN_OUTPUTS_APP_SLUG}[bot]" git config --global user.email "${STEPS_GET_USER_ID_OUTPUTS_USER_ID}+${STEPS_APP_TOKEN_OUTPUTS_APP_SLUG}[bot]@users.noreply.github.com" gh auth setup-git env: GH_TOKEN: ${{ steps.app-token.outputs.token }} STEPS_APP_TOKEN_OUTPUTS_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} STEPS_GET_USER_ID_OUTPUTS_USER_ID: ${{ steps.get-user-id.outputs.user-id }} - name: Commit and push if changed if: steps.check.outcome == 'failure' shell: bash run: | set -euo pipefail if git diff --quiet; then echo "No changes after fix hashes; nothing to commit." exit 0 fi git add --update --ignore-removal . git commit -m "chore(nix): auto-fix nix hashes" git push origin HEAD:dev --force-with-lease