Slack Workflow Run #14549
This file contains hidden or 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 Workflow Run | |
| on: | |
| workflow_run: | |
| types: | |
| - completed | |
| branches: | |
| - master | |
| - master-private | |
| - rc--* | |
| - ic-mainnet-revisions | |
| - ic-nervous-system-wasms | |
| tags: | |
| - release-* | |
| workflows: | |
| - Schedule Daily | |
| - Schedule Hourly | |
| - Schedule RC | |
| - Schedule Rust Benchmarks | |
| - Schedule Weekly | |
| - Release Testing | |
| - Publish Release | |
| - Container IC Base Images | |
| - PocketIC Windows | |
| - Sync IC private from IC public | |
| - Update mainnet ICOS versions file | |
| - Update mainnet canister versions file | |
| - CI Main | |
| - Bazel Dependency Submission | |
| jobs: | |
| slack-workflow-run: | |
| name: Send Notification | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup Message and Channels | |
| id: setup | |
| shell: bash | |
| run: | | |
| TRIGGERING_WORKFLOW_NAME="${{ github.event.workflow_run.name }}" | |
| TRIGGERING_WORKFLOW_BRANCH="${{ github.event.workflow_run.head_branch }}" | |
| CHANNEL="eng-idx-alerts" | |
| FULL_MESSAGE="nothing" | |
| # if a job was cancelled, never post it to slack | |
| if [[ "${{ github.event.workflow_run.conclusion }}" =~ ^(cancelled)$ ]]; then | |
| POST_TO_SLACK="false" | |
| echo "post_to_slack=${POST_TO_SLACK}" >> $GITHUB_OUTPUT | |
| exit 0 | |
| # if a job was successful, don't post it to slack, unless it was a release testing job (see below) | |
| elif [[ "${{ github.event.workflow_run.conclusion }}" =~ ^(success)$ ]]; then | |
| FULL_MESSAGE=":white_check_mark: ${MESSAGE} :relaxed:" | |
| POST_TO_SLACK="false" | |
| # if a job failed or timed out, always post it to slack | |
| elif [[ "${{ github.event.workflow_run.conclusion }}" =~ ^(failure|timed_out)$ ]]; then | |
| FULL_MESSAGE=":fire: ${MESSAGE} :disappointed:" | |
| POST_TO_SLACK="true" | |
| fi | |
| # If the job was release testing, modify the message and channel and post it to slack | |
| if [[ "$TRIGGERING_WORKFLOW_NAME" == "Release Testing" ]]; then | |
| CHANNEL="release-management-alerts" | |
| COMMIT="${{ github.event.workflow_run.head_sha }}" | |
| FULL_MESSAGE="${FULL_MESSAGE} commit: ${COMMIT}" | |
| POST_TO_SLACK="true" | |
| fi | |
| # Non-IDX alerts | |
| if [[ "$TRIGGERING_WORKFLOW_NAME" == "Schedule Rust Benchmarks" ]]; then | |
| CHANNEL="eng-crypto-alerts" | |
| elif [[ "$TRIGGERING_WORKFLOW_NAME" == "Update mainnet ICOS versions file" ]]; then | |
| CHANNEL="eng-consensus-alerts" | |
| elif [[ "$TRIGGERING_WORKFLOW_NAME" == "Update mainnet canister versions file" ]]; then | |
| CHANNEL="eng-nns" | |
| elif [[ "$TRIGGERING_WORKFLOW_NAME" == "CI Main" ]] && [[ "$TRIGGERING_WORKFLOW_BRANCH" == "ic-mainnet-revisions" ]]; then | |
| CHANNEL="eng-consensus-alerts" | |
| elif [[ "$TRIGGERING_WORKFLOW_NAME" == "CI Main" ]] && [[ "$TRIGGERING_WORKFLOW_BRANCH" == "ic-nervous-system-wasms" ]]; then | |
| CHANNEL="eng-nns" | |
| fi | |
| echo "channel=${CHANNEL}" >> $GITHUB_OUTPUT | |
| echo "message=${FULL_MESSAGE}" >> $GITHUB_OUTPUT | |
| echo "post_to_slack=${POST_TO_SLACK}" >> $GITHUB_OUTPUT | |
| env: | |
| MESSAGE: "*${{github.event.workflow_run.name}}* ${{github.event.workflow_run.conclusion}} on ${{github.event.workflow_run.head_branch}} - <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|Run#${{github.event.workflow_run.id}}>" | |
| - name: Post Slack Notification | |
| uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 | |
| if: ${{ steps.setup.outputs.post_to_slack == 'true' }} | |
| with: | |
| channel-id: ${{ steps.setup.outputs.channel }} | |
| slack-message: "${{ steps.setup.outputs.message }}" | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }} |