-
Notifications
You must be signed in to change notification settings - Fork 18
37 lines (32 loc) · 1.13 KB
/
deploy.yml
File metadata and controls
37 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Deploy
on:
workflow_run:
workflows: ["Python application"]
types: [completed]
jobs:
deploy:
runs-on: ubuntu-latest
if: >-
github.event.workflow_run.conclusion == 'success'
&& startsWith(github.event.workflow_run.head_branch, '20')
steps:
- name: Deploy ${{ github.event.workflow_run.head_branch }}
env:
WEBHOOK_SECRET: ${{ secrets.DEPLOY_WEBHOOK_SECRET }}
TAG: ${{ github.event.workflow_run.head_branch }}
run: |
PAYLOAD="{\"ref\":\"refs/tags/$TAG\"}"
SIGNATURE="sha256=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d' ' -f2)"
HTTP_CODE=$(curl -s --max-time 120 \
-o /tmp/deploy-output.txt \
-w "%{http_code}" \
-X POST \
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: $SIGNATURE" \
-d "$PAYLOAD" \
"https://dochub.be/webhook/dochub-deploy")
cat /tmp/deploy-output.txt
if [ "$HTTP_CODE" != "200" ]; then
echo "Webhook returned HTTP $HTTP_CODE"
exit 1
fi