Skip to content

Commit 213880c

Browse files
ci(pie-monorepo): DSW-2679 alert slack channel on CDN publish error (#2276)
1 parent de0615e commit 213880c

File tree

3 files changed

+77
-11
lines changed

3 files changed

+77
-11
lines changed

.changeset/pretty-spies-speak.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"pie-monorepo": minor
3+
---
4+
5+
[Added] - Alert an internal slack channel if CDN publishes fail

.github/workflows/changeset-release.yml

+71-10
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ jobs:
120120
PACKAGES='${{ steps.changesets-main.outputs.publishedPackages}}'
121121
PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]')
122122
REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]')
123-
123+
124124
PRIORITIZED_BLOCKS=$(echo $PACKAGES | jq -c '
125125
map(select(.name == "pie-docs" or .name == "pie-storybook")) |
126-
126+
127127
if length > 0 then
128128
[{"type": "divider"}, {"type": "header", "text": {"type": "plain_text", "text": ":rocket: Deployment Summary"}}] +
129129
(map(
@@ -170,8 +170,8 @@ jobs:
170170
.
171171
end
172172
')
173-
174-
173+
174+
175175
REST_COMPONENT_BLOCKS=$(echo $REST_PACKAGES | jq -c '
176176
if length > 0 then
177177
[{"type": "divider"}] +
@@ -183,9 +183,9 @@ jobs:
183183
[]
184184
end
185185
')
186-
186+
187187
BLOCKS=$(echo "[${PRIORITIZED_BLOCKS},${REST_COMPONENT_BLOCKS}]" | jq -c 'add')
188-
188+
189189
echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV
190190
191191
- name: Send a Slack notification on publish
@@ -201,8 +201,9 @@ jobs:
201201
}
202202
env:
203203
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
204-
204+
205205
- name: Publish packages to CDN
206+
id: cdn-publish
206207
if: steps.changesets-main.outputs.published == 'true'
207208
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
208209
env:
@@ -212,6 +213,66 @@ jobs:
212213
PIE_CDN_BUCKET_NAME: ${{ vars.PIE_CDN_BUCKET_NAME }}
213214
with:
214215
script: |
215-
const publishedPackages = JSON.parse('${{ steps.changesets-main.outputs.publishedPackages }}');
216-
const publishToCdn = require('${{ github.workspace }}/packages/tools/pie-monorepo-utils/pie-cdn/publish-to-cdn.js');
217-
await publishToCdn({ publishedPackages });
216+
try {
217+
const publishedPackages = JSON.parse('${{ steps.changesets-main.outputs.publishedPackages }}');
218+
const publishToCdn = require('${{ github.workspace }}/packages/tools/pie-monorepo-utils/pie-cdn/publish-to-cdn.js');
219+
await publishToCdn({ publishedPackages });
220+
} catch (error) {
221+
core.setFailed(`CDN publish failed: ${error.message}`);
222+
}
223+
224+
- name: Send Slack alert on CDN publish failure
225+
if: failure() && steps.cdn-publish.outcome == 'failure'
226+
uses: slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 # v1.27.1
227+
with:
228+
channel-id: ${{ secrets.ALERTS_SLACK_CHANNEL_ID }}
229+
payload: |
230+
{
231+
"blocks": [
232+
{
233+
"type": "section",
234+
"text": {
235+
"type": "mrkdwn",
236+
"text": ":warning: *CDN Publish Failed* :warning:\nThe CDN publishing step has failed for new package versions."
237+
}
238+
},
239+
{
240+
"type": "context",
241+
"elements": [
242+
{
243+
"type": "mrkdwn",
244+
"text": "*Workflow:* `${{ github.workflow }}`"
245+
}
246+
]
247+
},
248+
{
249+
"type": "actions",
250+
"elements": [
251+
{
252+
"type": "button",
253+
"text": {
254+
"type": "plain_text",
255+
"text": "View Workflow Run :github:",
256+
"emoji": true
257+
},
258+
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
259+
"style": "primary"
260+
},
261+
{
262+
"type": "button",
263+
"text": {
264+
"type": "plain_text",
265+
"text": "View Repository :octocat:",
266+
"emoji": true
267+
},
268+
"url": "https://github.com/${{ github.repository }}",
269+
"style": "primary"
270+
}
271+
]
272+
}
273+
]
274+
}
275+
env:
276+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
277+
278+

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,4 @@ jobs:
363363
with:
364364
# "allowed-skips" lists jobs that are optional but should not fail
365365
allowed-skips: browser-tests-components, deploy-docs, deploy-storybook, browser-tests-docs
366-
jobs: ${{ toJSON(needs) }}
366+
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)