-
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 8, 2024
1 parent
9bdb149
commit edb4ff1
Showing
2 changed files
with
38 additions
and
38 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 |
---|---|---|
|
@@ -17,45 +17,45 @@ on: | |
required: true | ||
|
||
jobs: | ||
Slack_notification: | ||
slack_notification: | ||
runs-on: ubuntu-latest | ||
steps: slack_notification | ||
- name: Prepare Slack Message | ||
if: ${{ steps.publish.outcome == 'success' && !contains(matrix.package, 'Meta') }} | ||
id: slack-prepare | ||
shell: bash | ||
env: | ||
SLACK_ID: ${{ inputs.slack_id }} | ||
run: | | ||
channel_id=$(echo "$SLACK_ID" | jq -r .\"${{ github.actor }}\") | ||
echo "::add-mask::$channel_id" | ||
echo SLACK_CHANNEL=$channel_id >> $GITHUB_ENV | ||
payload='{"blocks":[]}' | ||
if [[ ${{ inputs.slack_header }} != '']];then | ||
payload=$(echo "$payload" | jq '.blocks += [{"type": "section","text": {"type": "mrkdwn","text": "${{ inputs.slack_header }}"}}]') | ||
fi | ||
if [[ ${{ inputs.slack_message_body }} != '']];then | ||
payload=$(echo "$payload" | jq '.blocks += [{"type": "section","text": {"type": "mrkdwn","text": "${{ inputs.slack_message_body }}"}}]') | ||
fi | ||
if [[ ${{ inputs.slack_context }} != '']];then | ||
payload=$(echo "$payload" | jq '.blocks += [{"type": "context","elements":[{"type": "mrkdwn", "text": "${{ inputs.slack_message_body }}"}]}]') | ||
fi | ||
echo SLACK_PAYLOAD=$payload >> $GITHUB_ENV | ||
- name: Prepare Slack Message | ||
if: ${{ steps.publish.outcome == 'success' && !contains(matrix.package, 'Meta') }} | ||
id: slack-prepare | ||
shell: bash | ||
env: | ||
SLACK_ID: ${{ inputs.slack_id }} | ||
run: | | ||
channel_id=$(echo "$SLACK_ID" | jq -r .\"${{ github.actor }}\") | ||
echo "::add-mask::$channel_id" | ||
echo SLACK_CHANNEL=$channel_id >> $GITHUB_ENV | ||
payload='{"blocks":[]}' | ||
if [[ ${{ inputs.slack_header }} != '']];then | ||
payload=$(echo "$payload" | jq '.blocks += [{"type": "section","text": {"type": "mrkdwn","text": "${{ inputs.slack_header }}"}}]') | ||
fi | ||
if [[ ${{ inputs.slack_message_body }} != '']];then | ||
payload=$(echo "$payload" | jq '.blocks += [{"type": "section","text": {"type": "mrkdwn","text": "${{ inputs.slack_message_body }}"}}]') | ||
fi | ||
if [[ ${{ inputs.slack_context }} != '']];then | ||
payload=$(echo "$payload" | jq '.blocks += [{"type": "context","elements":[{"type": "mrkdwn", "text": "${{ inputs.slack_message_body }}"}]}]') | ||
fi | ||
echo SLACK_PAYLOAD=$payload >> $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=${{ inputs.slack_header }} >> $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=${{ inputs.slack_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=${{ inputs.slack_context }} >> $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=${{ inputs.slack_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: ${{ env.SLACK_PAYLOAD }} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ inputs.slack_token }} | ||
- name: Send to Slack | ||
id: slack | ||
if: steps.slack-prepare.outcome == 'success' | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: ${{ env.SLACK_CHANNEL }} | ||
payload: ${{ env.SLACK_PAYLOAD }} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ inputs.slack_token }} |
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