-
Notifications
You must be signed in to change notification settings - Fork 37
224 lines (193 loc) · 8.83 KB
/
release.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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: Release to Production
# Run this workflow every time a new commit is pushed to the master branch
# or a version branch (e.g. version-4-0)
on:
schedule:
- cron: '0 20 * * 1-5' # At 12:00 PM PST (8 PM UTC), Monday through Friday
- cron: '0 5 * * 2-6' # At 9:00 PM PST (5 AM UTC next day), Monday through Friday
- cron: '0 20 * * 6' # At 12:00 PM PST (8 PM UTC next day), Saturday - Due to Security Buletin Publication
- cron: '0 20 * * 0' # At 12:00 PM PST (8 PM UTC next day), Sunday - Due to Security Buletin Publication
workflow_dispatch:
inputs:
useGitHubHostedLargeRunner:
description: 'Use the GitHub-hosted large runner. Allowed values are true or false. Caution - this results in additional charges to the organization.'
required: false
default: 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_KEY }}
AWS_DEFAULT_REGION: us-east-1
APPZI_TOKEN: ${{ secrets.APPZI_TOKEN }}
FULLSTORY_ORGID: ${{ secrets.FULLSTORY_ORGID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_SEARCH_KEY: ${{ secrets.ALGOLIA_SEARCH_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
PALETTE_API_KEY: ${{ secrets.PALETTE_API_KEY }}
DISABLE_PACKS_INTEGRATIONS: ${{ secrets.DISABLE_PACKS_INTEGRATIONS }}
DISABLE_SECURITY_INTEGRATIONS: ${{ secrets.DISABLE_SECURITY_INTEGRATIONS }}
DSO_AUTH_TOKEN: ${{ secrets.DSO_AUTH_TOKEN }}
concurrency:
group: production-${{ github.workflow }}
cancel-in-progress: true
jobs:
# This is the default workflow that uses the self-hosted runner. The self-hosted runner is slower than the GitHub-hosted large runner, but it does not incurr additional charges.
build-self-hosted-runner:
if: ${{ github.event.inputs.useGitHubHostedLargeRunner != 'true' || github.event_name == 'schedule' }}
name: Build Website (Self-Hosted Runner)
runs-on: ["self-hosted", "linux", "x64", "vcenter3"]
steps:
- name: Force Failure
run: |
echo "CURRENT_STEP=Force Failure" >> $GITHUB_ENV
exit 1
- name: Checkout Repository
run: echo "CURRENT_STEP=Checkout Repository" >> $GITHUB_ENV
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "master"
- name: Setup Node.js environment
run: echo "CURRENT_STEP=Setup Node.js environment" >> $GITHUB_ENV
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: |
echo "CURRENT_STEP=npm ci" >> $GITHUB_ENV
npm ci
- name: Build
run: |
echo "CURRENT_STEP=Build" >> $GITHUB_ENV
touch .env
make versions-ci
make build-ci
- name: Build with cached packs
if: ${{ env.BUILD_EXIT_CODE == '5' }}
run: echo "CURRENT_STEP=Build with cached packs" >> $GITHUB_ENV
uses: ./.github/actions/build-cached-packs
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to AWS
run: |
echo "CURRENT_STEP=Upload to AWS" >> $GITHUB_ENV
aws s3 sync --cache-control 'public, max-age=604800' --exclude '*.html' --exclude '*.xml' --exclude build/scripts/ build/ s3://docs.spectrocloud.com --delete
aws s3 sync --cache-control 'public, max-age=0, s-maxage=604800' build/ s3://docs.spectrocloud.com --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*"
- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_PRIVATE_TEAM_WEBHOOK }}
SLACK_USERNAME: "spectromate"
SLACK_ICON_EMOJI: ":robot_panic:"
SLACK_COLOR: "danger"
SLACKIFY_MARKDOWN: true
ENABLE_ESCAPES: true
SLACK_MESSAGE: "The self-hosted runner release job for `${{ github.workflow }}` in `${{ github.repository }}` failed at step: `${{ env.CURRENT_STEP }}`. [View details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
# Use this workflow if you want to use the GitHub-hosted large runner. Useful for scenarios when you need a change to deploy faster than the self-hosted runner can build it.
build-large-runner:
if: ${{ github.event.inputs.useGitHubHostedLargeRunner == 'true' && github.event_name != 'schedule' }}
name: Build Website (GitHub-Hosted Large Runner)
runs-on:
group: 'Doc Runners'
labels: docbot
steps:
- name: Checkout Repository
run: echo "CURRENT_STEP=Checkout Repository" >> $GITHUB_ENV
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "master"
- name: Setup Node.js environment
run: echo "CURRENT_STEP=Setup Node.js environment" >> $GITHUB_ENV
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: |
echo "CURRENT_STEP=npm ci" >> $GITHUB_ENV
npm ci
- name: Versions
run: |
echo "CURRENT_STEP=Versions" >> $GITHUB_ENV
- name: Build
run: |
echo "CURRENT_STEP=Build" >> $GITHUB_ENV
touch .env
make versions-ci
make build-ci
- name: Build with cached packs
run: echo "CURRENT_STEP=Build with cached packs" >> $GITHUB_ENV
if: ${{ env.BUILD_EXIT_CODE == '5' }}
uses: ./.github/actions/build-cached-packs
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to AWS
run: |
echo "CURRENT_STEP=Upload to AWS" >> $GITHUB_ENV
aws s3 sync --cache-control 'public, max-age=604800' --exclude '*.html' --exclude '*.xml' --exclude build/scripts/ build/ s3://docs.spectrocloud.com --delete
aws s3 sync --cache-control 'public, max-age=0, s-maxage=604800' build/ s3://docs.spectrocloud.com --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*"
- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_PRIVATE_TEAM_WEBHOOK }}
SLACK_USERNAME: "spectromate"
SLACK_ICON_EMOJI: ":robot_panic:"
SLACK_COLOR: "danger"
SLACKIFY_MARKDOWN: true
ENABLE_ESCAPES: true
SLACK_MESSAGE: "The large runner release job for `${{ github.workflow }}` in `${{ github.repository }}` failed at step: `${{ env.CURRENT_STEP }}`. [View details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
release:
name: "Release"
if: always() && (needs.build-large-runner.result == 'success' || needs.build-self-hosted-runner.result == 'success')
needs: [build-self-hosted-runner,build-large-runner]
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout Repository
run: echo "CURRENT_STEP=Checkout Repository" >> $GITHUB_ENV
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Retrieve Credentials
run: echo "CURRENT_STEP=Retrieve Credentials" >> $GITHUB_ENV
id: import-secrets
uses: hashicorp/[email protected]
with:
url: https://vault.prism.spectrocloud.com
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: /providers/github/organizations/spectrocloud/token?org_name=spectrocloud token | VAULT_GITHUB_TOKEN
- name: Setup Nodejs
run: echo "CURRENT_STEP=Setup Nodejs" >> $GITHUB_ENV
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: |
echo "CURRENT_STEP=Install dependencies" >> $GITHUB_ENV
npm ci
- name: "release"
env:
GITHUB_TOKEN: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}
run: |
echo "CURRENT_STEP=release" >> $GITHUB_ENV
npx semantic-release
- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_PRIVATE_TEAM_WEBHOOK }}
SLACK_USERNAME: "spectromate"
SLACK_ICON_EMOJI: ":robot_panic:"
SLACK_COLOR: "danger"
SLACKIFY_MARKDOWN: true
ENABLE_ESCAPES: true
SLACK_MESSAGE: "The release job for `${{ github.workflow }}` in `${{ github.repository }}` failed at step: `${{ env.CURRENT_STEP }}`. [View details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."