Check for tests or deployment results #216
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: Check for tests or deployment results | |
on: | |
workflow_run: | |
workflows: ["CI"] | |
types: [completed] | |
jobs: | |
notify-slack: | |
runs-on: ubuntu-latest | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
steps: | |
- name: Extract Slack ID for author | |
id: extract_slack_id | |
run: | | |
#!/bin/bash | |
# user_string="johndoe:U12345678, janedoe:U87654321, alice:U98765432" | |
user_string="${{ vars.SLACK_USER_IDS }}" | |
suid="" | |
IFS=", " read -r -a users <<< "$user_string" | |
for user in "${users[@]}"; do | |
IFS=':' read -r github_username slack_user_id <<< "$user" | |
if [ "$github_username" == "${{github.actor}}" ]; then | |
suid="$slack_user_id" | |
break | |
fi | |
done | |
echo "::set-output name=suid::$suid" | |
- name: tests | |
uses: ravsamhq/notify-slack-action@v2 | |
if: ${{ github.event.workflow_run.head_branch != 'main' && github.event.workflow_run.head_branch != 'staging' && github.event.workflow_run.head_branch != 'production' }} | |
with: | |
status: ${{ github.event.workflow_run.conclusion }} | |
notification_title: "Tests ${{github.event.workflow_run.conclusion}} on *${{github.event.workflow_run.head_branch}}* - <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View ${{github.event.workflow_run.conclusion}}>" | |
message_format: "{emoji} *${{github.event.workflow_run.name}}* ${{github.event.workflow_run.conclusion}} in <{repo_url}|{repo}>" | |
footer: "Linked Repo <${{github.server_url}}/${{github.repository}}|${{github.repository}}> | <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View ${{github.event.workflow_run.conclusion}}>" | |
mention_users: ${{ steps.extract_slack_id.outputs.suid }} | |
mention_users_when: "failure,warnings" |