diff --git a/.github/actions/slack-alert/action.yml b/.github/actions/slack-alert/action.yml index 72365ef51f..e22e46d2f0 100644 --- a/.github/actions/slack-alert/action.yml +++ b/.github/actions/slack-alert/action.yml @@ -8,6 +8,14 @@ inputs: slack_token: description: Slack token required: true + message: + description: The message to send to Slack + default: The last '${{ github.workflow }}' run failed. See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + required: false + color: + description: The color of the Slack message + default: failure + required: false runs: using: composite @@ -17,5 +25,5 @@ runs: with: channel: ${{ inputs.slack_channel_id }} bot-token: ${{ inputs.slack_token }} - color: failure - text: The last '${{ github.workflow }}' run failed. See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + color: ${{ inputs.color }} + text: ${{ inputs.message }} diff --git a/.github/workflows/alert-changed-branch-protections.yml b/.github/workflows/alert-changed-branch-protections.yml index 7f68108ea0..d075b0df56 100644 --- a/.github/workflows/alert-changed-branch-protections.yml +++ b/.github/workflows/alert-changed-branch-protections.yml @@ -38,10 +38,19 @@ jobs: id: compare run: | # Compare the fetched branch protections with the committed ones - git diff --no-index .github/branch_protection_settings/${{ matrix.branch }}.json ${{ matrix.branch }}-actual.json + git diff --no-index .github/branch_protection_settings/${{ matrix.branch }}.json ${{ matrix.branch }}-actual.json || echo "diff_failed=true" >> $GITHUB_ENV + + - name: Set failure message + if: env.diff_failed == 'true' + run: | + message="Alert due to changes in branch protections for ${{ matrix.branch }}. Please review the changes and ensure they are intentional. If valid, update the branch protection settings in .github/branch_protection_settings/${{ matrix.branch }}.json to match the diff in this workflow." + echo "failure_message=$message" >> $GITHUB_ENV + echo "$message" - uses: ./.github/actions/slack-alert - if: ${{ failure() && github.event_name != 'workflow_dispatch' }} + if: ${{ env.diff_failed == 'true' && github.event_name != 'workflow_dispatch' }} with: slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} + message: ${{ env.failure_message }} + color: purple