-
Notifications
You must be signed in to change notification settings - Fork 14
152 lines (148 loc) · 5.83 KB
/
cd.yaml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: cd
on:
# Uncomment to work on CD in development mode.
# pull_request:
# branches: [master]
push:
branches:
- master
jobs:
deploy_to_dev:
runs-on: ubuntu-latest
env:
ENV: 'dev'
steps:
# This Clean step simply checks if there's already a workflow running from the last
# commit and cancels it if there is. This helps us save on cloud cost in the long run.
# See https://github.com/rokroskar/workflow-run-cleanup-action for more information.
- name: Clean
uses: rokroskar/workflow-run-cleanup-action@v0.2.2
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
if: "github.ref != 'refs/heads/master'"
- name: Checkout Repo
uses: actions/checkout@v2
- name: Auth with Gcloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_DEV_SA_KEY }}
- name: Set up Gcloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: zesty-dev
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16.5.0'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build-dev
- name: Deploy to Dev
run: gcloud app deploy app.yaml --quiet --project zesty-dev
- name: Post Successful Dev Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: |
Use :eyes: to signal you have seen this message.
Use :white_check_mark: to signal you have successfully manually tested the deployed changes.
Use :x: to signal manual tests on deployed changes were unsuccessful and start a thread under this alert describing your remediation steps.
SLACK_TITLE: Successfully Deployed accounts-ui to Dev
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
cancel_workflow_if_dev_deploy_failed:
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- deploy_to_dev
steps:
- name: Post Failed Dev Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: 'PR merge by ${{ github.actor }} has failed to deploy to dev.'
SLACK_TITLE: Dev Deployment Failed for accounts-ui
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Cancel current workflow run
uses: actions/github-script@v4
with:
script: |
github.actions.cancelWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
})
deploy_to_stage:
runs-on: ubuntu-latest
env:
ENV: 'stage'
needs:
- deploy_to_dev
steps:
# This Clean step simply checks if there's already a workflow running from the last
# commit and cancels it if there is. This helps us save on cloud cost in the long run.
# See https://github.com/rokroskar/workflow-run-cleanup-action for more information.
- name: Clean
uses: rokroskar/workflow-run-cleanup-action@v0.2.2
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
if: "github.ref != 'refs/heads/master'"
- name: Checkout Repo
uses: actions/checkout@v2
- name: Auth with Gcloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Gcloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: zesty-stage
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16.5.0'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build-stage
- name: Deploy to Staging
run: gcloud app deploy app.yaml --quiet --project zesty-stage
- name: Post Successful Stage Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: |
Use :eyes: to signal you have seen this message.
Use :white_check_mark: to signal you have successfully manually tested the deployed changes.
Use :x: to signal manual tests on deployed changes were unsuccessful and start a thread under this alert describing your remediation steps.
SLACK_TITLE: Successfully Deployed accounts-ui to Stage
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
post_failed_stage_deploy_notification_to_slack:
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- deploy_to_stage
steps:
- name: Post Failed Staging Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: 'PR merge by ${{ github.actor }} has failed to deploy to staging.'
SLACK_TITLE: Staging Deployment Failed for accounts-ui
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}