Slack branch existence notification #14482
Workflow file for this run
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
name: Slack branch existence notification | |
on: | |
create: | |
delete: | |
jobs: | |
notify: | |
name: Notify | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 # 2022-11-22: Shouldn't take long. | |
if: github.event.ref == 'prerelease' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: trunk | |
- name: Generate message | |
id: message | |
run: | | |
source .github/files/gh-funcs.sh | |
if [[ "$GITHUB_EVENT_NAME" == 'create' ]]; then | |
gh_set_output message "$( | |
jq -nc --slurpfile event "$GITHUB_EVENT_PATH" '$event[0] as $e | { | |
icon_emoji: ":lock:", | |
text: "Incoming release! Prerelease branch was created by \( $e.sender.login ).", | |
blocks: [ | |
{ | |
type: "section", | |
text: { | |
type: "mrkdwn", | |
text: ":holdontoyourbutts: Incoming release! Prerelease branch was created by \( $e.sender.login ).", | |
}, | |
} | |
], | |
}' | |
)" | |
elif [[ "$GITHUB_EVENT_NAME" == 'delete' ]]; then | |
gh_set_output message "$( | |
jq -nc --slurpfile event "$GITHUB_EVENT_PATH" '$event[0] as $e | { | |
icon_emoji: ":unlock:", | |
text: "Prerelease branch was deleted by \( $e.sender.login ).", | |
blocks: [ | |
{ | |
type: "section", | |
text: { | |
type: "mrkdwn", | |
text: "Prerelease branch was deleted by \( $e.sender.login ).", | |
}, | |
} | |
], | |
}' | |
)" | |
else | |
echo "::error::Unknown event \"$GITHUB_EVENT_NAME\"" | |
exit 1 | |
fi | |
- name: Send message to releases channel | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_RELEASES_CHANNEL }} | |
payload: ${{ steps.message.outputs.message }} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} |