Skip to content

Commit 2da0045

Browse files
committed
[DEVPLAT-2283] Update job-notification action to use blocks and take thread ts
1 parent 3446062 commit 2da0045

File tree

1 file changed

+50
-39
lines changed

1 file changed

+50
-39
lines changed

Diff for: action.yml

+50-39
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
channel:
1414
description: The Slack channel name for receiving the notification
1515
required: true
16+
slack-ts:
17+
description: The timestamp of the message to update
18+
required: false
19+
default: ''
1620
status:
1721
description: Customize the notification status to be "success", "failure" or a custom value.
1822
required: false
@@ -68,44 +72,51 @@ runs:
6872
6973
- name: Send notification
7074
if: always()
71-
uses: slackapi/[email protected]
72-
env:
73-
SLACK_BOT_TOKEN: ${{ inputs.token }}
75+
uses: archive/[email protected]
7476
with:
75-
channel-id: ${{ inputs.channel }}
76-
payload: |
77-
{
78-
"text": ":${{ steps.fields.outputs.emoji }}: *Workflow <https://github.com/${{ inputs.repository }}/actions/runs/${{ github.run_id }}/|${{ github.workflow }}> ${{ inputs.status }}*",
79-
"attachments": [
80-
{
81-
"color": "${{ steps.fields.outputs.color }}",
82-
"fields": [
83-
{
84-
"title": "Repository",
85-
"value": "<https://github.com/${{ inputs.repository }}|${{ inputs.repository }}>",
86-
"short": true
87-
},
88-
{
89-
"title": "Environment/Branch",
90-
"value": "${{ inputs.environment || github.ref_name }}",
91-
"short": true
92-
},
93-
{
94-
"title": "Author",
95-
"value": "<https://github.com/${{ steps.fields.outputs.author }}|${{ steps.fields.outputs.author }}>",
96-
"short": true
97-
},
98-
{
99-
"title": "Job",
100-
"value": "${{ github.job }}",
101-
"short": true
102-
},
103-
{
104-
"title": "Commit Message",
105-
"value": ${{ toJSON(steps.fields.outputs.message) }},
106-
"short": false
107-
}
108-
]
77+
slack-channel: ${{ inputs.channel }}
78+
slack-bot-user-oauth-access-token: ${{ inputs.token }}
79+
slack-optional-thread_ts: ${{ inputs.slack-ts }}
80+
slack-blocks: >-
81+
[
82+
{
83+
"type": "section",
84+
"text": {
85+
"type": "mrkdwn",
86+
"text": ":${{ steps.fields.outputs.emoji }}: *Workflow <https://github.com/${{ inputs.repository }}/actions/runs/${{ github.run_id }}/|${{ github.workflow }}> ${{ inputs.status }}*"
87+
}
88+
},
89+
{
90+
"type": "section",
91+
"fields": [
92+
{
93+
"type": "mrkdwn",
94+
"text": "*Repository*\n<https://github.com/${{ inputs.repository }}|${{ inputs.repository }}>"
95+
},
96+
{
97+
"type": "mrkdwn",
98+
"text": "*Environment/Branch*\n${{ inputs.environment || github.ref_name }}"
99+
}
100+
]
101+
},
102+
{
103+
"type": "section",
104+
"fields": [
105+
{
106+
"type": "mrkdwn",
107+
"text": "*Author*\n<https://github.com/${{ steps.fields.outputs.author }}|${{ steps.fields.outputs.author }}>"
108+
},
109+
{
110+
"type": "mrkdwn",
111+
"text": "*Job*\n${{ github.job }}"
112+
}
113+
]
114+
},
115+
{
116+
"type": "section",
117+
"text": {
118+
"type": "mrkdwn",
119+
"text": "*Commit Message*\n${{ steps.fields.outputs.message }}"
109120
}
110-
]
111-
}
121+
}
122+
]

0 commit comments

Comments
 (0)