forked from willnorris/imageproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (199 loc) · 8.71 KB
/
deploy-safeimage.yml
File metadata and controls
209 lines (199 loc) · 8.71 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: safeimage
on:
push:
branches:
- main
- master
workflow_dispatch:
inputs:
forceDeploymentType:
description: 'Leave Empty or use "production" or "staging"'
required: false
default: ""
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
jobs:
send_slack_message_and_assess_deployment:
name: send slack message and assess deployment
runs-on: [ self-hosted, aws ]
outputs:
dockerImageRepo: ${{ steps.getDeploymentConfiguration.outputs.dockerImageRepo }}
slackChannelId: ${{ steps.getDeploymentConfiguration.outputs.slackChannelId }}
deploymentType: ${{ steps.getDeploymentConfiguration.outputs.deploymentType }}
dockerFile: ${{ steps.getDeploymentConfiguration.outputs.dockerFile }}
slackFollowUpMessageId: ${{ steps.slackStartingMessage.outputs.slackMessageId }}
steps:
- name: Checkout current repo
uses: actions/checkout@v2
- name: Checkout actions repo
uses: actions/checkout@v2
with:
repository: bufferapp/deploy-actions
path: deploy-actions
token: ${{ secrets.GH_ACTIONS_WORKFLOW_TRIGGER_TOKEN }}
- name: Get deployment configuration
id: getDeploymentConfiguration
uses: ./deploy-actions/assess-deployment
- name: Send Starting Message
id: slackStartingMessage
uses: ./deploy-actions/slack-send-pipeline-notification
with:
channel-id: ${{ steps.getDeploymentConfiguration.outputs.slackChannelId }}
notification-type: "PIPELINE-BEGIN"
build_and_push_docker_image:
name: Build & Push Docker Image
runs-on: [self-hosted, aws]
needs:
- send_slack_message_and_assess_deployment
steps:
- name: Checkout current repo
uses: actions/checkout@v2
- name: Checkout actions repo
uses: actions/checkout@v2
with:
repository: bufferapp/deploy-actions
path: deploy-actions
token: ${{ secrets.GH_ACTIONS_WORKFLOW_TRIGGER_TOKEN }}
- name: Check if Docker image exists
id: dockerImageExistenceCheck
continue-on-error: true
with:
dockerRepoName: ${{ needs.send_slack_message_and_assess_deployment.outputs.dockerImageRepo }}
uses: ./deploy-actions/docker-image-exist-check
- name: Notify on start build
uses: ./deploy-actions/slack-send-pipeline-notification
with:
channel-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackChannelId }}
notification-message: "Docker Build Process Will Now Start"
notification-type: "INFO"
slack-message-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackFollowUpMessageId }}
- name: Build and push Docker image
uses: ./deploy-actions/build-and-push-docker-image
if: ${{ steps.dockerImageExistenceCheck.outcome == 'failure' }}
with:
dockerRepoName: ${{ needs.send_slack_message_and_assess_deployment.outputs.dockerImageRepo }}
deploymentType: ${{ needs.send_slack_message_and_assess_deployment.outputs.deploymentType }}
dockerFile: ${{ needs.send_slack_message_and_assess_deployment.outputs.dockerFile }}
generate_helm_commands:
name: Generate Helm Commands
runs-on: [self-hosted, aws]
outputs:
helmCommandList: ${{ steps.generateHelmCommands.outputs.helmCommandList }}
deploymentUrl: ${{ steps.generateHelmCommands.outputs.deploymentUrl }}
needs:
- send_slack_message_and_assess_deployment
- build_and_push_docker_image
steps:
- name: Checkout current repo
uses: actions/checkout@v2
- name: Checkout actions repo
uses: actions/checkout@v2
with:
repository: bufferapp/deploy-actions
path: deploy-actions
token: ${{ secrets.GH_ACTIONS_WORKFLOW_TRIGGER_TOKEN }}
- name: Notify on Generating Helm Commands
uses: ./deploy-actions/slack-send-pipeline-notification
with:
channel-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackChannelId }}
notification-message: "Generating Helm Commands ..."
notification-type: "INFO"
slack-message-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackFollowUpMessageId }}
- name: Generate Helm Commands
uses: ./deploy-actions/generate-helm-commands
id: generateHelmCommands
with:
githubToken: ${{ secrets.PERMISSIVE_TOKEN }}
deploymentType: ${{ github.event.inputs.forceDeploymentType || needs.send_slack_message_and_assess_deployment.outputs.deploymentType }}
execute_helm_commands:
name: Run Helm
runs-on: [self-hosted, aws]
needs:
- send_slack_message_and_assess_deployment
- generate_helm_commands
strategy:
matrix:
include: ${{fromJson(needs.generate_helm_commands.outputs.helmCommandList)}}
steps:
- name: Checkout current repo
uses: actions/checkout@v2
- name: Checkout actions repo
uses: actions/checkout@v2
with:
repository: bufferapp/deploy-actions
path: deploy-actions
token: ${{ secrets.GH_ACTIONS_WORKFLOW_TRIGGER_TOKEN }}
- name: Notify on Service Deploy
uses: ./deploy-actions/slack-send-pipeline-notification
if: ${{ always() && contains((github.event.inputs.itemsToDeploy || matrix.name), matrix.name) }}
with:
channel-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackChannelId }}
notification-message: "Deploying ${{ matrix.name }}"
notification-type: "INFO"
slack-message-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackFollowUpMessageId }}
- name: Run Helm Command
uses: ./deploy-actions/run-helm-command
if: ${{ always() && contains((github.event.inputs.itemsToDeploy || matrix.name), matrix.name) }}
with:
helmCommand: ${{ matrix.command }}
deploymentUrl: ${{ needs.generate_helm_commands.outputs.deploymentUrl }}
githubToken: ${{ secrets.PERMISSIVE_TOKEN }}
- name: Notify on Service Deploy
uses: ./deploy-actions/slack-send-pipeline-notification
if: ${{ always() && contains((github.event.inputs.itemsToDeploy || matrix.name), matrix.name) }}
with:
channel-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackChannelId }}
notification-message: "Deployed ${{ matrix.name }}"
notification-type: "INFO"
slack-message-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackFollowUpMessageId }}
do_final_reporting:
name: Do Final Reporting
runs-on: [self-hosted, aws]
needs:
- send_slack_message_and_assess_deployment
- execute_helm_commands
steps:
- name: Checkout current repo
uses: actions/checkout@v2
- name: Checkout actions repo
uses: actions/checkout@v2
with:
repository: bufferapp/deploy-actions
path: deploy-actions
token: ${{ secrets.GH_ACTIONS_WORKFLOW_TRIGGER_TOKEN }}
- name: Report Deployment To Velocity
id: reportToVelocity
continue-on-error: true
uses: ./deploy-actions/velocity-pipeline-report
with:
token: ${{ secrets.VELOCITY_DEPLOYMENT_TOKEN }}
version: ${{ github.sha }}
environment: ${{ github.workflow }}-${{ needs.send_slack_message_and_assess_deployment.outputs.deploymentType }}
- name: Send Success Message
id: slackSuccessMessage
uses: ./deploy-actions/slack-send-pipeline-notification
with:
channel-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackChannelId }}
slack-message-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackFollowUpMessageId }}
notification-type: "PIPELINE-SUCCESS"
report_on_failure:
name: Report On Failure
runs-on: [ self-hosted, aws ]
needs:
- send_slack_message_and_assess_deployment
- execute_helm_commands
if: ${{ always() && (needs.execute_helm_commands.result!='success') }}
steps:
- name: Checkout actions repo
uses: actions/checkout@v2
with:
repository: bufferapp/deploy-actions
path: deploy-actions
token: ${{ secrets.GH_ACTIONS_WORKFLOW_TRIGGER_TOKEN }}
- name: Send Failure Message
id: slackFailureMessage
uses: ./deploy-actions/slack-send-pipeline-notification
with:
channel-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackChannelId }}
slack-message-id: ${{ needs.send_slack_message_and_assess_deployment.outputs.slackFollowUpMessageId }}
notification-type: "PIPELINE-FAIL"