Update #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Slack | |
on: | |
push: | |
branches: | |
- slack | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
pull-requests: write | |
steps: | |
- name: Get package information | |
id: package_info | |
run: | | |
CHANGES='[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]' | |
echo "changes=${CHANGES}" >> $GITHUB_OUTPUT | |
- name: Send custom JSON data to Slack workflow | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
# This data can be any valid JSON from a previous step in the GitHub Action | |
payload: | | |
${run: | |
const changes = JSON.parse(steps.package_info.outputs.changes); | |
const blocks = []; | |
blocks.push({ | |
type: "section", | |
text: { | |
type: "mrkdwn", | |
text: `🎉 New release of ${steps.package_info.outputs.name} (${steps.package_info.outputs.version}) is available!` | |
} | |
}); | |
changes.forEach(package => { | |
blocks.push({ | |
type: "section", | |
fields: [ | |
{ | |
type: "mrkdwn", | |
text: `*Package Name:*\n${package.name}` | |
}, | |
{ | |
type: "mrkdwn", | |
text: `*Version:*\n${package.version}` | |
} | |
] | |
}); | |
}); | |
return { blocks }; | |
} | |
env: | |
SLACK_WEBHOOK_URL: "https://hooks.slack.com/services/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" |