Deploy on Webhook #118
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
| # ---------------------------------------------------------------------------- | |
| # Deploy on Webhook Workflow | |
| # This workflow triggers a deployment webhook only after the "Pytest" | |
| # workflow has successfully completed on the main branch. | |
| # ---------------------------------------------------------------------------- | |
| name: Deploy on Webhook | |
| on: | |
| workflow_run: | |
| # Trigger only after "Pytest" completes on the main branch. The | |
| # branches: filter restricts the trigger itself — without it the | |
| # workflow would fire on every branch's Pytest run and then be | |
| # gated only by the job-level if, which is noisy in the Actions tab. | |
| workflows: | |
| - "Pytest" | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| # Belt-and-suspenders: re-check that the upstream Pytest run both | |
| # succeeded AND was on main. In a workflow_run context github.ref | |
| # refers to the triggered workflow itself; the head_branch field | |
| # holds the branch where the upstream Pytest actually ran. | |
| if: >- | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.head_branch == 'main' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| # Step: Trigger the external deployment webhook | |
| - name: Trigger Deployment Webhook | |
| env: | |
| WEBHOOK_DOMAIN: ${{ secrets.WEBHOOK_DOMAIN }} | |
| WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }} | |
| run: | | |
| curl -X POST \ | |
| https://${{ secrets.WEBHOOK_DOMAIN }}/webhook/deploy \ | |
| -H "Authorization: Bearer ${{ secrets.WEBHOOK_TOKEN }}" |