Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Trigger staging back-sync on release | |
| # On a published release, notify the staging repo to sync from production immediately. | |
| # This workflow is dispatch-only: it cannot write production or staging contents. | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'sentdm/sent-dm-python' | |
| env: | |
| STAGING_REPO: sentdm/sent-dm-python-staging | |
| steps: | |
| - name: Dispatch back-sync to staging | |
| env: | |
| DISPATCH_TOKEN: ${{ secrets.STAGING_DISPATCH_TOKEN }} | |
| REF_NAME: ${{ github.ref_name }} | |
| run: | | |
| set -euo pipefail | |
| [ -n "${DISPATCH_TOKEN:-}" ] || { echo "STAGING_DISPATCH_TOKEN not set" >&2; exit 1; } | |
| payload=$(jq -n --arg ref "$REF_NAME" '{event_type:"prod-released",client_payload:{ref:$ref}}') | |
| code=$(curl -sS -o /tmp/dispatch.txt -w '%{http_code}' -X POST \ | |
| -H "Authorization: Bearer ${DISPATCH_TOKEN}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "https://api.github.com/repos/${STAGING_REPO}/dispatches" \ | |
| -d "$payload") | |
| if [ "$code" = "204" ]; then | |
| echo "Back-sync dispatched to ${STAGING_REPO}." | |
| else | |
| echo "Dispatch failed (HTTP $code)" >&2; cat /tmp/dispatch.txt >&2; exit 1 | |
| fi |