Skip to content

Commit afd9317

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 afd9317

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

.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."

0 commit comments

Comments
 (0)