forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (191 loc) · 7.31 KB
/
Copy pathrelease.yml
File metadata and controls
209 lines (191 loc) · 7.31 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: Make Release and Deploy
run-name: RELEASE ${{ github.run_number }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
deployStrategy:
description: 'Deploy Strategy'
default: 'Recreate'
required: true
type: choice
options:
- Recreate
- RollingUpdate
- Current
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
# -----------------------------------------------------------------
# PREPARE
# -----------------------------------------------------------------
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
buildVersion: ${{ steps.buildvars.outputs.buildVersion }}
previousVersion: ${{ steps.semver.outputs.current }}
baseImageVersion: ${{ steps.baseimgversion.outputs.baseImageVersion }}
steps:
- name: Ensure release branch
if: github.ref != 'refs/heads/release'
run: |
echo "This workflow can only run on the 'release' branch (current: ${{ github.ref_name }})"
exit 1
- uses: actions/checkout@v7
with:
fetch-depth: 1
fetch-tags: false
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: release
skipInvalidTags: true
patchList: fix, bugfix, perf, refactor, test, tests, chore
- name: Create Draft Release
uses: ncipollo/release-action@v1.21.0
with:
prerelease: true
draft: false
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.nextStrict }}
name: ${{ steps.semver.outputs.nextStrict }}
body: '*pending*'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Build Variables
id: buildvars
run: |
echo "Will set build version to: ${{ steps.semver.outputs.nextStrict }}"
echo "buildVersion=${{ steps.semver.outputs.nextStrict }}" >> $GITHUB_OUTPUT
echo "::notice::Release ${{ steps.semver.outputs.nextStrict }} created using branch $GITHUB_REF_NAME"
- name: Get Base Image Target Version
id: baseimgversion
run: |
echo "baseImageVersion=$(sed -n '1p' dev/build/TARGET_BASE)" >> $GITHUB_OUTPUT
# -----------------------------------------------------------------
# TESTS
# -----------------------------------------------------------------
tests:
name: Run Tests
uses: ./.github/workflows/reusable-tests.yml
needs: [prepare]
secrets: inherit
with:
ignoreLowerCoverage: false
skipSelenium: true
targetBaseVersion: ${{ needs.prepare.outputs.baseImageVersion }}
# -----------------------------------------------------------------
# BUILD RELEASE
# -----------------------------------------------------------------
build:
name: Build Release Image
uses: ./.github/workflows/reusable-build.yml
if: ${{ !failure() && !cancelled() }}
needs: [tests, prepare]
permissions:
contents: write
packages: write
secrets: inherit
with:
buildVersion: ${{needs.prepare.outputs.buildVersion}}
isReleaseBuild: true
previousVersion: ${{needs.prepare.outputs.previousVersion}}
handleCoverageResults: true
updateCoverageBaseline: true
baseImageVersion: ${{ needs.prepare.outputs.baseImageVersion }}
# -----------------------------------------------------------------
# NOTIFY
# -----------------------------------------------------------------
notify:
name: Notify
if: ${{ always() }}
needs: [prepare, tests, build]
runs-on: ubuntu-latest
env:
BUILD_VERSION: ${{needs.prepare.outputs.buildVersion}}
steps:
- name: Notify on Slack (Success)
if: ${{ !contains(join(needs.*.result, ','), 'failure') }}
uses: slackapi/slack-github-action@v3
with:
token: ${{ secrets.SLACK_GH_BOT }}
method: chat.postMessage
payload: |
channel: ${{ secrets.SLACK_GH_BUILDS_CHANNEL_ID }}
text: "Datatracker Release Build <https://github.com/ietf-tools/datatracker/actions/runs/${{ github.run_id }}|${{ env.BUILD_VERSION }}> by ${{ github.triggering_actor }}"
attachments:
- color: "28a745"
fields:
- title: "Status"
short: true
value: "Completed"
- name: Notify on Slack (Failure)
if: ${{ contains(join(needs.*.result, ','), 'failure') }}
uses: slackapi/slack-github-action@v3
with:
token: ${{ secrets.SLACK_GH_BOT }}
method: chat.postMessage
payload: |
channel: ${{ secrets.SLACK_GH_BUILDS_CHANNEL_ID }}
text: "Datatracker Release Build <https://github.com/ietf-tools/datatracker/actions/runs/${{ github.run_id }}|${{ env.BUILD_VERSION }}> by ${{ github.triggering_actor }}"
attachments:
- color: "a82929"
fields:
- title: "Status"
short: true
value: "Failed 😱"
# -----------------------------------------------------------------
# STAGING
# -----------------------------------------------------------------
staging:
name: Deploy to Staging
if: ${{ !failure() && !cancelled() }}
needs: [prepare, build]
runs-on: ubuntu-latest
environment:
name: staging
env:
BUILD_VERSION: ${{needs.prepare.outputs.buildVersion}}
steps:
- name: Refresh Staging DB
uses: ietf-tools/workflow-dispatch-action@v1
with:
workflow: deploy-db.yml
repo: ietf-tools/infra-k8s
ref: main
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
inputs: '{ "environment":"${{ secrets.GHA_K8S_CLUSTER }}", "app":"datatracker", "manifest":"postgres", "forceRecreate":true, "restoreToLastFullSnapshot":true, "waitClusterReady":true }'
waitForCompletionTimeout: 120m
- name: Deploy to staging
uses: ietf-tools/workflow-dispatch-action@v1
with:
workflow: deploy.yml
repo: ietf-tools/infra-k8s
ref: main
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
inputs: '{ "environment":"${{ secrets.GHA_K8S_CLUSTER }}", "app":"datatracker", "appVersion":"${{ env.BUILD_VERSION }}", "remoteRef":"${{ github.sha }}", "deployStrategy":"${{ inputs.deployStrategy }}" }'
waitForCompletionTimeout: 30m
# -----------------------------------------------------------------
# PROD
# -----------------------------------------------------------------
prod:
name: Deploy to Production
if: ${{ !failure() && !cancelled() }}
needs: [prepare, staging]
runs-on: ubuntu-latest
environment:
name: production
env:
BUILD_VERSION: ${{needs.prepare.outputs.buildVersion}}
steps:
- name: Deploy to production
uses: ietf-tools/workflow-dispatch-action@v1
with:
workflow: deploy.yml
repo: ietf-tools/infra-k8s
ref: main
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
inputs: '{ "environment":"${{ secrets.GHA_K8S_CLUSTER }}", "app":"datatracker", "appVersion":"${{ env.BUILD_VERSION }}", "remoteRef":"${{ github.sha }}", "deployStrategy":"${{ inputs.deployStrategy }}" }'
waitForCompletionTimeout: 30m