|
32 | 32 | jobs: |
33 | 33 |
|
34 | 34 | # Define a job for detecting broken links in Markdown files... |
35 | | - check_links: |
| 35 | + markdown_links: |
36 | 36 |
|
37 | 37 | # Define a display name: |
38 | 38 | name: 'Check links' |
|
75 | 75 | if: ${{ steps.results.outputs.status }} != 'success' |
76 | 76 | run: | |
77 | 77 | exit 1 |
| 78 | +
|
| 79 | + # Define a job for sending notifications to Slack... |
| 80 | + slack: |
| 81 | + |
| 82 | + # Define a display name: |
| 83 | + name: 'Slack notification' |
| 84 | + |
| 85 | + # Define the type of virtual host machine: |
| 86 | + runs-on: 'ubuntu-latest' |
| 87 | + |
| 88 | + # Indicate that this job depends on the prior job finishing: |
| 89 | + needs: markdown_links |
| 90 | + |
| 91 | + # Run this job regardless of the outcome of the prior job: |
| 92 | + if: always() |
| 93 | + |
| 94 | + # Set defaults: |
| 95 | + defaults: |
| 96 | + run: |
| 97 | + # Set the default shell to `bash`: |
| 98 | + shell: bash --noprofile --norc -eo pipefail {0} |
| 99 | + |
| 100 | + # Define the sequence of job steps... |
| 101 | + steps: |
| 102 | + |
| 103 | + # Resolve notification data: |
| 104 | + - name: 'Resolve notification data' |
| 105 | + run: | |
| 106 | + echo 'NOTIFICATION_STATUS=${{ needs.markdown_links.result}}' >> $GITHUB_ENV |
| 107 | + if [[ "${{ needs.markdown_links.result }}" = "success" ]]; then |
| 108 | + echo 'NOTIFICATION_TEXT=**markdown_links** workflow succeeded' >> $GITHUB_ENV |
| 109 | + echo 'NOTIFICATION_AUTHOR_NAME=Success' >> $GITHUB_ENV |
| 110 | + elif [[ "${{ needs.markdown_links.result }}" = "failure" ]]; then |
| 111 | + echo 'NOTIFICATION_TEXT=**markdown_links** workflow failed' >> $GITHUB_ENV |
| 112 | + echo 'NOTIFICATION_AUTHOR_NAME=Failure' >> $GITHUB_ENV |
| 113 | + elif [[ "${{ needs.markdown_links.result }}" = "cancelled" ]]; then |
| 114 | + echo 'NOTIFICATION_TEXT=**markdown_links** workflow was canceled' >> $GITHUB_ENV |
| 115 | + echo 'NOTIFICATION_AUTHOR_NAME=Canceled' >> $GITHUB_ENV |
| 116 | + else |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + timeout-minutes: 5 |
| 120 | + |
| 121 | + # Send notification to Slack: |
| 122 | + - name: 'Send notification' |
| 123 | + uses: 8398a7/action-slack@v3 |
| 124 | + if: success() |
| 125 | + with: |
| 126 | + status: "${{ env.NOTIFICATION_STATUS }}" |
| 127 | + fields: repo,commit,message |
| 128 | + text: "${{ env.NOTIFICATION_TEXT }}" |
| 129 | + author_name: "${{ env.NOTIFICATION_AUTHOR_NAME }}" |
| 130 | + env: |
| 131 | + SLACK_WEBHOOK_URL: ${{ secrets.REPO_SLACK_WEBHOOK_URL }} |
| 132 | + timeout-minutes: 5 |
0 commit comments