Skip to content

Commit 3cf411e

Browse files
author
BotReleaser
committed
Add more slack notif ideas
1 parent b53ce12 commit 3cf411e

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

.github/workflows/post-release.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- post-release
77
# Client payload should contain
88
# version_name: vX.Y.Z (with prefix)
9-
# slack_thread_id: (Also named thread_ts == thread timestamp)
9+
# slack_thread_id: (Also named thread_ts == thread timestamp == timestamp of the first message)
1010
permissions:
1111
contents: write
1212

@@ -21,6 +21,7 @@ jobs:
2121
organization: Giskard-AI
2222
username: ${{ github.actor }}
2323
token: ${{ secrets.GITHUB_TOKEN }}
24+
2425
- name: Interrupt job
2526
if: ${{ steps.is_organization_member.outputs.result == 'false' }}
2627
shell: bash
@@ -106,23 +107,36 @@ jobs:
106107
- name: Push to Pipy
107108
run: pdm publish --no-build --username "${{ secrets.PIPY_USERNAME }}" --password "${{ secrets.PIPY_PASSWORD }}"
108109

110+
- name: Set job success env var
111+
run: |
112+
echo "JOB_SUCCESS=true" >> $GITHUB_ENV
113+
109114
- name: Post Slack message
115+
# # cancellable always() https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
116+
if: !cancelled()
110117
id: slack
111118
uses: slackapi/slack-github-action@v1.24.0
119+
env:
120+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
121+
ON_SUCCESS: |
122+
<!channel>
123+
Release **${{ env.VERSION_NAME }}** has been published ! :tada:
124+
[Release notes](${{ steps.github-release.outputs.url }}) | [PyPI](https://pypi.org/project/giskard/${{ env.VERSION_NUMBER }})
125+
Github releases: \
126+
[Library](${{ github.server_url }}/${{ github.repository_owner }}/giskard/releases/tag/${{ env.VERSION_NUMBER }}) | \
127+
[Hub](${{ github.server_url }}/${{ github.repository_owner }}/giskard-hub/releases/tag/${{ env.VERSION_NUMBER }})
128+
ON_FAILURE: |
129+
"<!channel> Release ${{ env.VERSION_NAME }} failed on post-release :cross:
130+
[Logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
112131
with:
113132
# Slack channel id, channel name, or user id to post message.
114133
# See also: https://api.slack.com/methods/chat.postMessage#channels
115134
# On special mentions: https://api.slack.com/reference/surfaces/formatting#special-mentions
116135
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
117-
slack-message: |
118-
<!channel> New library release: ${{ env.VERSION_NAME }} :tada:
119-
[Release notes](${{ steps.github-release.outputs.url }}) | [PyPI](https://pypi.org/project/giskard/${{ env.VERSION_NUMBER }})
136+
slack-message: ${{ env.JOB_SUCCESS == 'true' && env.ON_SUCCESS || env.ON_FAILURE }}
120137
# reploy_broadcast == also send to channel
121138
payload: |
122139
{
123140
"thread_ts": "${{ inputs.slack_thread_id }}",
124141
"reply_broadcast": true
125142
}
126-
# For posting a rich message using Block Kit
127-
env:
128-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 commit comments

Comments
 (0)