File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Trigger staging back-sync on release
2+
3+ # On a published release, notify the staging repo to sync from production immediately.
4+ # This workflow is dispatch-only: it cannot write production or staging contents.
5+ on :
6+ release :
7+ types : [published]
8+ workflow_dispatch : {}
9+
10+ permissions :
11+ contents : read
12+
13+ jobs :
14+ notify :
15+ runs-on : ubuntu-latest
16+ if : github.repository == 'sentdm/sent-dm-python'
17+ env :
18+ STAGING_REPO : sentdm/sent-dm-python-staging
19+ steps :
20+ - name : Dispatch back-sync to staging
21+ env :
22+ DISPATCH_TOKEN : ${{ secrets.STAGING_DISPATCH_TOKEN }}
23+ REF_NAME : ${{ github.ref_name }}
24+ run : |
25+ set -euo pipefail
26+ [ -n "${DISPATCH_TOKEN:-}" ] || { echo "STAGING_DISPATCH_TOKEN not set" >&2; exit 1; }
27+ payload=$(jq -n --arg ref "$REF_NAME" '{event_type:"prod-released",client_payload:{ref:$ref}}')
28+ code=$(curl -sS -o /tmp/dispatch.txt -w '%{http_code}' -X POST \
29+ -H "Authorization: Bearer ${DISPATCH_TOKEN}" \
30+ -H "Accept: application/vnd.github+json" \
31+ -H "X-GitHub-Api-Version: 2022-11-28" \
32+ "https://api.github.com/repos/${STAGING_REPO}/dispatches" \
33+ -d "$payload")
34+ if [ "$code" = "204" ]; then
35+ echo "Back-sync dispatched to ${STAGING_REPO}."
36+ else
37+ echo "Dispatch failed (HTTP $code)" >&2; cat /tmp/dispatch.txt >&2; exit 1
38+ fi
You can’t perform that action at this time.
0 commit comments