-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update job-notification action to use blocks and take thread ts
- Loading branch information
1 parent
3446062
commit 30617df
Showing
1 changed file
with
50 additions
and
39 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 |
---|---|---|
|
@@ -13,6 +13,10 @@ inputs: | |
channel: | ||
description: The Slack channel name for receiving the notification | ||
required: true | ||
slack-ts: | ||
description: The timestamp of the message to update | ||
required: false | ||
default: '' | ||
status: | ||
description: Customize the notification status to be "success", "failure" or a custom value. | ||
required: false | ||
|
@@ -68,44 +72,51 @@ runs: | |
- name: Send notification | ||
if: always() | ||
uses: slackapi/[email protected] | ||
env: | ||
SLACK_BOT_TOKEN: ${{ inputs.token }} | ||
uses: archive/[email protected] | ||
with: | ||
channel-id: ${{ inputs.channel }} | ||
payload: | | ||
{ | ||
"text": ":${{ steps.fields.outputs.emoji }}: *Workflow <https://github.com/${{ inputs.repository }}/actions/runs/${{ github.run_id }}/|${{ github.workflow }}> ${{ inputs.status }}*", | ||
"attachments": [ | ||
{ | ||
"color": "${{ steps.fields.outputs.color }}", | ||
"fields": [ | ||
{ | ||
"title": "Repository", | ||
"value": "<https://github.com/${{ inputs.repository }}|${{ inputs.repository }}>", | ||
"short": true | ||
}, | ||
{ | ||
"title": "Environment/Branch", | ||
"value": "${{ inputs.environment || github.ref_name }}", | ||
"short": true | ||
}, | ||
{ | ||
"title": "Author", | ||
"value": "<https://github.com/${{ steps.fields.outputs.author }}|${{ steps.fields.outputs.author }}>", | ||
"short": true | ||
}, | ||
{ | ||
"title": "Job", | ||
"value": "${{ github.job }}", | ||
"short": true | ||
}, | ||
{ | ||
"title": "Commit Message", | ||
"value": ${{ toJSON(steps.fields.outputs.message) }}, | ||
"short": false | ||
} | ||
] | ||
slack-channel: ${{ inputs.channel }} | ||
slack-bot-user-oauth-access-token: ${{ inputs.token }} | ||
slack-optional-thread_ts: ${{ inputs.slack-ts }} | ||
slack-blocks: >- | ||
[ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": ":${{ steps.fields.outputs.emoji }}: *Workflow <https://github.com/${{ inputs.repository }}/actions/runs/${{ github.run_id }}/|${{ github.workflow }}> ${{ inputs.status }}*" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Repository*\n<https://github.com/${{ inputs.repository }}|${{ inputs.repository }}>" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Environment/Branch*\n${{ inputs.environment || github.ref_name }}" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "section", | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Author*\n<https://github.com/${{ steps.fields.outputs.author }}|${{ steps.fields.outputs.author }}>" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Job*\n${{ github.job }}" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Commit Message*\n${{ toJSON(steps.fields.outputs.message) }}" | ||
} | ||
] | ||
} | ||
} | ||
] |