-
Notifications
You must be signed in to change notification settings - Fork 248
47 lines (41 loc) · 1.44 KB
/
deloyment_on_webhook.yml
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
38
39
40
41
42
43
44
45
46
47
name: Deploy on Webhook
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_run:
workflows:
- "Python Lint"
- "Run tests"
types:
- completed
jobs:
deploy:
if: >-
github.event.workflow_run.conclusion == 'success' &&
(github.event.workflow_run.name == 'Python Lint' || github.event.workflow_run.name == 'Run tests')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Trigger Deployment Webhook
env:
WEBHOOK_DOMAIN: ${{ secrets.WEBHOOK_DOMAIN }}
WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }}
run: |
# Check if both lint and test workflows succeeded
if [[ "${{ github.event.workflow_run.name }}" == "Python Lint" && "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then
echo "Python Lint completed successfully."
echo "lint_success=1" >> $GITHUB_ENV
fi
if [[ "${{ github.event.workflow_run.name }}" == "Run tests" && "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then
echo "Run tests completed successfully."
echo "test_success=1" >> $GITHUB_ENV
fi
- name: Deploy if both succeeded
if: env.lint_success == '1' && env.test_success == '1'
run: |
curl -X POST https://${{ secrets.WEBHOOK_DOMAIN }}/webhook/deploy -H "Authorization: Bearer ${{ secrets.WEBHOOK_TOKEN }}"