Skip to content

Commit 83b97b6

Browse files
committed
fix(ci): fix slack payload parsing and prevent notification failures from blocking CI
The release publish workflow failed because the Slack payload contained unescaped multi-line mrkdwn content that broke the webhook action's parser. This caused code coverage to be skipped since the job halted on the Slack error. - Build a proper JSON payload via jq instead of raw string interpolation - Use env vars for changesets output to avoid command injection - Add continue-on-error to Slack steps so notifications never block the pipeline
1 parent 04ae8bb commit 83b97b6

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,23 @@ jobs:
102102
- name: Format published packages for Slack
103103
if: steps.changesets.outputs.published == 'true'
104104
id: format-packages
105+
env:
106+
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
105107
run: |
106-
PACKAGES=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | ":package: *\(.name)* `\(.version)`"')
107-
echo "formatted<<EOF" >> $GITHUB_OUTPUT
108-
echo "$PACKAGES" >> $GITHUB_OUTPUT
108+
FORMATTED=$(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | ":package: *\(.name)* `\(.version)`"')
109+
PAYLOAD=$(jq -n --arg packages "$FORMATTED" '{"publishedPackages": $packages}')
110+
echo "payload<<EOF" >> $GITHUB_OUTPUT
111+
echo "$PAYLOAD" >> $GITHUB_OUTPUT
109112
echo "EOF" >> $GITHUB_OUTPUT
110113
111114
- name: Send GitHub Action data to a Slack workflow
112115
if: steps.changesets.outputs.published == 'true'
116+
continue-on-error: true
113117
uses: slackapi/slack-github-action@v2.1.1
114118
with:
115-
payload-delimiter: '_'
116119
webhook: ${{ env.SLACK_WEBHOOK_URL }}
117120
webhook-type: webhook-trigger
118-
payload: |
119-
publishedPackages: ${{ steps.format-packages.outputs.formatted }}
121+
payload: ${{ steps.format-packages.outputs.payload }}
120122

121123
- name: Run code coverage
122124
uses: codecov/codecov-action@v5
@@ -159,6 +161,7 @@ jobs:
159161

160162
- name: Send GitHub Action data to a Slack workflow
161163
if: steps.npmpublish.outcome == 'success'
164+
continue-on-error: true
162165
uses: slackapi/slack-github-action@v2.1.1
163166
with:
164167
payload-delimiter: '_'

0 commit comments

Comments
 (0)