hetzner-cloud-1/.forgejo/workflows/deploy-flake-update.yml
Markus Zoppelt df7df176f5
Some checks failed
update-flake-lock.yml / ci: deploy merged flake.lock updates (push) Failing after 0s
ci: deploy merged flake.lock updates
Merging the scheduled flake.lock pull request queues a host switch.
The job only writes the merge SHA; the host re-checks that main is a
lockfile-only bot bump before nixos-rebuild switch, so a runner restart
cannot roll the deploy back.
2026-11-06 09:54:04 +01:00

43 lines
1.5 KiB
YAML

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"