mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-18 06:04:56 +00:00
f13f35644d
Adds step-security/harden-runner (audit, pinned to v2.22.4 like craft-common-actions) as the first step of each job that did not have it, so every workflow in the org's public repos reports its egress to StepSecurity. Audit, not block: block-mode allow lists come from each job's observed traffic.
58 lines
1.9 KiB
YAML
58 lines
1.9 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@1d88384fd173af6ecb012dfd0264a306b711241a # 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
|