-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vladyslav Hlushchenko
committed
Apr 5, 2024
1 parent
cb15565
commit 057d9bc
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: 'Hello World' | ||
description: 'Greet someone' | ||
inputs: | ||
slack_header: # id of input | ||
required: true | ||
default: 'Default Slack Header' | ||
slack_context: | ||
required: true | ||
default: 'Default Slack Context' | ||
slack_id: | ||
required: true | ||
outputs: | ||
random-number: | ||
description: "Random number" | ||
value: ${{ steps.random-number-generator.outputs.random-number }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Prepare Slack Message | ||
if: ${{ steps.publish.outcome == 'success' && !contains(matrix.package, 'Meta') }} | ||
id: slack-prepare | ||
shell: bash | ||
run: | | ||
channel_id=$(echo "${}" | jq -r .\"${{ github.actor }}\") | ||
echo "::add-mask::$channel_id" | ||
echo SLACK_CHANNEL=$channel_id >> $GITHUB_ENV | ||
header="Package *${{ matrix.package }}* version *${{ matrix.version }}* published to <https://www.npmjs.com/package/$(jq -r .name "packages/${{ matrix.package }}/package.json")/v/${{ matrix.version }}|NPM>" | ||
echo SLACK_MESSAGE_HEADER=$header >> $GITHUB_ENV | ||
context="*GitHub Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }} ${{ github.run_number }}>\n*Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|$(echo "${{ github.sha }}" | cut -c1-8) $(echo -e "${{ github.event.head_commit.message }}" | head -n1 | sed -e 's/"/\\"/g')>" | ||
echo SLACK_MESSAGE_CONTEXT=$context >> $GITHUB_ENV | ||
- name: Send to Slack | ||
id: slack | ||
if: steps.slack-prepare.outcome == 'success' | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: ${{ env.SLACK_CHANNEL }} | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ env.SLACK_MESSAGE_HEADER }}" | ||
} | ||
}, | ||
{ | ||
"type": "context", | ||
"elements": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "${{ env.SLACK_MESSAGE_CONTEXT }}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACKBOT_TOKEN }} |