@@ -102,32 +102,67 @@ docker stack deploy -c docker/swarm/stacks/oncall/stack-oncall.yml oncall
102102
103103## GHA Integration
104104
105- Trigger an on-demand Gantry update from a GitHub Actions workflow:
105+ Trigger an on-demand Gantry update from a GitHub Actions workflow using an ephemeral Tailscale connection :
106106
107107``` yaml
108+ - name : Setup and connect to Tailscale network
109+ uses : tailscale/github-action@53acf823325fe9ca47f4cdaa951f90b4b0de5bb9 # v4
110+ with :
111+ oauth-client-id : ${{ secrets.TS_OAUTH_CLIENT_ID }}
112+ oauth-secret : ${{ secrets.TS_OAUTH_SECRET }}
113+ hostname : gha-${{ env.STACK_NAME }}-deploy-${{ github.run_id }}
114+ tags : tag:ci
115+ version : latest
116+
117+ - name : Wait for Tailscale Network Readiness
118+ run : |
119+ echo "Waiting for Tailscale network to be ready..."
120+ max_wait=60
121+ elapsed=0
122+ while [ $elapsed -lt $max_wait ]; do
123+ if tailscale status --json | jq -e '.BackendState == "Running"' > /dev/null 2>&1; then
124+ echo "Tailscale network is ready"
125+ break
126+ fi
127+ sleep 2
128+ elapsed=$((elapsed + 2))
129+ done
130+ if [ $elapsed -ge $max_wait ]; then
131+ echo "Tailscale network not ready after ${max_wait}s"
132+ exit 1
133+ fi
134+
108135 - name : Trigger deployment
109136 run : |
110- curl -X POST https://${{ secrets.WEBHOOK_HOST }}/hooks/run-gantry \
137+ curl -fsS - X POST https://${{ secrets.WEBHOOK_HOST }}/hooks/run-gantry \
111138 -H "Content-Type: application/json" \
112139 -H "X-Webhook-Secret: ${{ secrets.WEBHOOK_SECRET }}" \
113140 -d '{"GANTRY_SERVICES_FILTERS":"name=${{ env.STACK_NAME }}_${{ env.SERVICE_NAME }}"}'
114141` ` `
115142
143+ **Required GHA secrets:** ` TS_OAUTH_CLIENT_ID`, `TS_OAUTH_SECRET`, `WEBHOOK_HOST` (Tailscale hostname), `WEBHOOK_SECRET`
144+
116145# # Testing Webhook
117146
118- Manual curl examples for verifying the webhook service :
147+ Run from the manager node (`ssh freecodecamp@ops-vm-backoffice`) :
119148
120149` ` ` bash
121- # Valid request (with secret header)
150+ # Trigger update for a specific service
151+ curl -X POST http://localhost:9889/hooks/run-gantry \
152+ -H "Content-Type: application/json" \
153+ -H "X-Webhook-Secret: $WEBHOOK_SECRET" \
154+ -d '{"GANTRY_SERVICES_FILTERS":"name=<stack>_<service>"}'
155+
156+ # Trigger update for all autoupdate-labeled services (no filter)
122157curl -X POST http://localhost:9889/hooks/run-gantry \
123158 -H "Content-Type: application/json" \
124- -H "X-Webhook-Secret : YOUR_SECRET_HERE " \
125- -d '{"GANTRY_SERVICES_FILTERS":"name=mystack_myservice" }'
159+ -H "X-Webhook-Secret: $WEBHOOK_SECRET " \
160+ -d '{}'
126161
127- # Invalid request (without secret — should be rejected )
162+ # Invalid request (no secret — should return "Hook rules were not satisfied" )
128163curl -X POST http://localhost:9889/hooks/run-gantry \
129164 -H "Content-Type: application/json" \
130- -d '{"GANTRY_SERVICES_FILTERS":"name=mystack_myservice" }'
165+ -d '{}'
131166
132167# Check webhook logs
133168docker service logs oncall_svc-webhook
0 commit comments