Files
artcraft-services/.github/workflows/deploy.yml
Dylan M. Taylor e938767d26 ci: lock workflow actions through an actions.lock lockfile
Mutable action tags are a supply-chain risk: a moved tag runs different code
without a diff. Every workflow action is now pinned through
.github/workflows/actions.lock, and CI verifies the lockfile so an out-of-sync
or tampered one fails instead of running.
2026-11-12 07:19:43 -05:00

58 lines
1.8 KiB
YAML

name: Trigger Cloudflare deploy
on:
push:
branches: [main, cloudflare-dev]
workflow_dispatch:
permissions: {}
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
with:
egress-policy: audit
- name: Verify target branch
if: github.event_name == 'workflow_dispatch'
run: |
case "${GITHUB_REF}" in
refs/heads/main|refs/heads/cloudflare-dev) ;;
*)
echo "Manual deploy hook runs must target main or cloudflare-dev (got ${GITHUB_REF})" >&2
exit 1
;;
esac
- name: Trigger Cloudflare build
env:
DEPLOY_HOOK: ${{ secrets.CLOUDFLARE_DEPLOY_HOOK }}
run: |
if [ -z "$DEPLOY_HOOK" ]; then
echo "CLOUDFLARE_DEPLOY_HOOK is not configured" >&2
exit 1
fi
max_attempts=4
delay=2
for attempt in $(seq 1 "$max_attempts"); do
status=$(curl --silent --show-error --output /tmp/cf-deploy-hook.out --write-out "%{http_code}" \
--connect-timeout 10 --max-time 30 --request POST "$DEPLOY_HOOK") || status="000"
if [ "$status" -ge 200 ] && [ "$status" -lt 300 ]; then
cat /tmp/cf-deploy-hook.out
exit 0
fi
if [ "$status" = "503" ] && [ "$attempt" -lt "$max_attempts" ]; then
echo "Cloudflare deploy hook returned HTTP 503 (attempt ${attempt}/${max_attempts}); retrying in ${delay}s..." >&2
sleep "$delay"
delay=$((delay * 2))
continue
fi
cat /tmp/cf-deploy-hook.out >&2 || true
echo "Cloudflare deploy hook request failed with HTTP ${status}" >&2
exit 1
done