Skip to content

Commit

Permalink
feat: Update job-notification action to use blocks and take thread ts
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmills committed Dec 5, 2024
1 parent 3446062 commit df11bda
Showing 1 changed file with 51 additions and 38 deletions.
89 changes: 51 additions & 38 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,44 +72,53 @@ runs:
- name: Send notification
if: always()
uses: slackapi/slack-github-[email protected].0
uses: archive/github-[email protected].0
env:
SLACK_BOT_TOKEN: ${{ inputs.token }}
MESSAGE: ${{ toJSON(steps.fields.outputs.message) }}
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${{ env.MESSAGE }}'
}
]
}
}
]

0 comments on commit df11bda

Please sign in to comment.