-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (98 loc) · 3.04 KB
/
environment-test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: "Environment Test"
# Check out the documentation for more info:
# - https://help.github.com/en/articles/workflow-syntax-for-github-actions
# - https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
on:
workflow_dispatch
jobs:
check-migrations:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main'
outputs:
has-migrations: ${{ steps.whatchanged.outputs.has-migrations }}
steps:
- uses: actions/checkout@v3
- id: whatchanged
name: whatchanged
run: |
echo "::set-output name=has-migrations::no"
output-validation:
runs-on: ubuntu-20.04
needs: check-migrations
if: needs.check-migrations.outputs.has-migrations != 'yes' && needs.check-migrations.outputs.has-migrations != 'no'
steps:
- name: Notify about invalid output
run: |
echo "The 'check-migrations' job produced invalid output:"
echo "${{needs.check-migrations.outputs.has-migrations}}"
exit 1
run-migrations:
runs-on: ubuntu-20.04
needs: check-migrations
timeout-minutes: 1 # We set a timeout simply to avoid accidentally wasting too many CI minutes.
if: needs.check-migrations.outputs.has-migrations == 'yes'
environment:
# A manual confirmation is enforced using environment protection rules.
name: run-migrations
steps:
- name: Waiting for migations to have run
run: |
echo "Waiting for migrations to complete..."
echo ${{needs.check-migrations.outputs.has-migrations}}
############ Post-migration Deployment Pipeline ############
deploy-after-migrations:
runs-on: ubuntu-20.04
needs: run-migrations
steps:
- name: Notify about deployment
run: |
echo "The following PRs changed..."
deploy-after-migrations-aws:
name: deploy-aws
runs-on: ubuntu-20.04
needs: deploy-after-migrations
environment:
name: production aws
steps:
- name: Deploy to AWS
run: |
echo "Deploying..."
deploy-after-migrations-azure:
name: deploy-azure
runs-on: ubuntu-20.04
needs: deploy-after-migrations
environment:
name: production azure
steps:
- name: Deploy to Azure
run: |
echo "Deploying..."
############ Direct Deployment Pipeline ############
deploy-directly:
runs-on: ubuntu-20.04
needs: check-migrations
if: needs.check-migrations.outputs.has-migrations == 'no'
steps:
- name: Notify about deployment
run: |
echo "The following PRs changed..."
deploy-directly-aws:
name: deploy-aws
runs-on: ubuntu-20.04
needs: deploy-directly
environment:
name: production aws
steps:
- name: Deploy to AWS
run: |
echo "Deploying..."
deploy-directly-azure:
name: deploy-azure
runs-on: ubuntu-20.04
needs: deploy-directly
environment:
name: production azure
steps:
- name: Deploy to Azure
run: |
echo "Deploying..."