Skip to content

Commit e4ed683

Browse files
committed
fix(ci): unify slack notifications for snapshot and publish jobs
- Snapshot job now reads package.json files to build a real payload instead of hardcoding empty publishedPackages - Both jobs use the same jq-based JSON payload construction - Add warning annotations when Slack notifications fail so failures are visible in the Actions summary without blocking the pipeline
1 parent 83b97b6 commit e4ed683

4 files changed

Lines changed: 2886 additions & 8159 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
- uses: actions/setup-node@v4
1919
id: cache
2020
with:
21-
node-version: '20.10.0'
22-
cache: 'pnpm'
21+
node-version: "20.10.0"
22+
cache: "pnpm"
2323

2424
- run: pnpm install --frozen-lockfile
2525

@@ -37,7 +37,7 @@ jobs:
3737
- run: pnpm exec nx affected -t build lint test docs e2e-ci
3838

3939
- name: Publish previews to Stackblitz on PR
40-
run: pnpm pkg-pr-new publish './packages/*' --packageManager=pnpm
40+
run: pnpm pkg-pr-new publish './packages/*' --packageManager=pnpm --pnpm
4141

4242
- uses: codecov/codecov-action@v5
4343
with:

.github/workflows/publish.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,19 @@ jobs:
113113
114114
- name: Send GitHub Action data to a Slack workflow
115115
if: steps.changesets.outputs.published == 'true'
116+
id: slack-notify
116117
continue-on-error: true
117118
uses: slackapi/slack-github-action@v2.1.1
118119
with:
119120
webhook: ${{ env.SLACK_WEBHOOK_URL }}
120121
webhook-type: webhook-trigger
121122
payload: ${{ steps.format-packages.outputs.payload }}
122123

124+
- name: Warn if Slack notification failed
125+
if: steps.slack-notify.outcome == 'failure'
126+
run: |
127+
echo "::warning::Slack notification failed. Check the webhook URL and payload format."
128+
123129
- name: Run code coverage
124130
uses: codecov/codecov-action@v5
125131
with:
@@ -159,14 +165,29 @@ jobs:
159165
id: npmpublish
160166
run: pnpm publish -r --tag ${{ inputs.npm_tag }} --no-git-checks --access ${{ inputs.npm_access }}
161167

168+
- name: Format published packages for Slack
169+
if: steps.npmpublish.outcome == 'success'
170+
id: format-packages
171+
env:
172+
NPM_TAG: ${{ inputs.npm_tag }}
173+
run: |
174+
FORMATTED=$(jq -rs '.[] | ":package: *\(.name)* `\(.version)`"' packages/*/package.json)
175+
PAYLOAD=$(jq -n --arg packages "$FORMATTED" --arg npmTag "$NPM_TAG" '{"npmTag": $npmTag, "publishedPackages": $packages}')
176+
echo "payload<<EOF" >> $GITHUB_OUTPUT
177+
echo "$PAYLOAD" >> $GITHUB_OUTPUT
178+
echo "EOF" >> $GITHUB_OUTPUT
179+
162180
- name: Send GitHub Action data to a Slack workflow
163181
if: steps.npmpublish.outcome == 'success'
182+
id: slack-notify-beta
164183
continue-on-error: true
165184
uses: slackapi/slack-github-action@v2.1.1
166185
with:
167-
payload-delimiter: '_'
168186
webhook: ${{ env.SLACK_WEBHOOK_URL_BETA }}
169187
webhook-type: webhook-trigger
170-
payload: |
171-
npmTag: "${{ inputs.npm_tag }}"
172-
publishedPackages: ""
188+
payload: ${{ steps.format-packages.outputs.payload }}
189+
190+
- name: Warn if Slack notification failed
191+
if: steps.slack-notify-beta.outcome == 'failure'
192+
run: |
193+
echo "::warning::Slack beta notification failed. Check the webhook URL and payload format."

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"mkcert": "^3.2.0",
9696
"npm-cli-login": "^1.0.0",
9797
"nx": "20.3.3",
98-
"pkg-pr-new": "^0.0.60",
98+
"pkg-pr-new": "^0.0.63",
9999
"playwright": "1.47.2",
100100
"prettier": "^3.2.5",
101101
"pretty-quick": "^4.0.0",

0 commit comments

Comments
 (0)