name: Deploy flake.lock update # pull_request_target reads this file from main, not from the bot branch. # The job does not check out the pull request. It only hands the merge SHA # to the host, which deploys on its own so a runner restart cannot roll the # switch back. on: pull_request_target: types: [closed] branches: [main] concurrency: group: deploy-flake-update cancel-in-progress: false jobs: deploy: if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'chore/update-flake-lock' runs-on: ubuntu-latest container: options: "--volume /run/deploy-flake:/run/deploy-flake" steps: - name: Queue host deploy env: MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} run: | set -euo pipefail case "$MERGE_SHA" in *[!0-9a-f]*|"") echo "refusing empty or non-hex merge sha" >&2 exit 1 ;; esac if [ ! -d /run/deploy-flake ]; then echo "host deploy trigger is missing; deploy this config once with: nix run .#deploy" >&2 exit 1 fi tmp=$(mktemp /run/deploy-flake/request.XXXXXX) printf '%s\n' "$MERGE_SHA" > "$tmp" mv "$tmp" /run/deploy-flake/request echo "Queued deploy of ${MERGE_SHA}." echo "The switch runs on the host, detached from this job." echo "journalctl -u deploy-flake-update"