Skip to content

Commit 4dbf15f

Browse files
committed
Add auto-deploy workflow triggered by tag push
1 parent 474c5b1 commit 4dbf15f

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Python application"]
6+
types: [completed]
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
if: >-
12+
github.event.workflow_run.conclusion == 'success'
13+
&& startsWith(github.event.workflow_run.head_branch, '20')
14+
steps:
15+
- name: Trigger deploy webhook
16+
env:
17+
WEBHOOK_SECRET: ${{ secrets.DEPLOY_WEBHOOK_SECRET }}
18+
run: |
19+
REF="refs/tags/${{ github.event.workflow_run.head_branch }}"
20+
PAYLOAD="{\"ref\":\"$REF\"}"
21+
SIGNATURE="sha256=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d' ' -f2)"
22+
RESPONSE=$(curl -sf --max-time 120 \
23+
-X POST \
24+
-H "Content-Type: application/json" \
25+
-H "X-Hub-Signature-256: $SIGNATURE" \
26+
-d "$PAYLOAD" \
27+
"https://dochub.be/webhook/dochub-deploy")
28+
echo "$RESPONSE"

.github/workflows/python-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Python application
33
on:
44
push:
55
branches: [ main ]
6+
tags:
7+
- '20*'
68
pull_request:
79

810
jobs:

0 commit comments

Comments
 (0)