Update branch protections workflow for clarity (#52312)
This commit is contained in:
12
.github/actions/slack-alert/action.yml
vendored
12
.github/actions/slack-alert/action.yml
vendored
@@ -8,6 +8,14 @@ inputs:
|
|||||||
slack_token:
|
slack_token:
|
||||||
description: Slack token
|
description: Slack token
|
||||||
required: true
|
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:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
@@ -17,5 +25,5 @@ runs:
|
|||||||
with:
|
with:
|
||||||
channel: ${{ inputs.slack_channel_id }}
|
channel: ${{ inputs.slack_channel_id }}
|
||||||
bot-token: ${{ inputs.slack_token }}
|
bot-token: ${{ inputs.slack_token }}
|
||||||
color: failure
|
color: ${{ inputs.color }}
|
||||||
text: The last '${{ github.workflow }}' run failed. See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
text: ${{ inputs.message }}
|
||||||
|
|||||||
@@ -38,10 +38,19 @@ jobs:
|
|||||||
id: compare
|
id: compare
|
||||||
run: |
|
run: |
|
||||||
# Compare the fetched branch protections with the committed ones
|
# 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
|
- uses: ./.github/actions/slack-alert
|
||||||
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
|
if: ${{ env.diff_failed == 'true' && github.event_name != 'workflow_dispatch' }}
|
||||||
with:
|
with:
|
||||||
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
|
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
|
||||||
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
|
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
|
||||||
|
message: ${{ env.failure_message }}
|
||||||
|
color: purple
|
||||||
|
|||||||
Reference in New Issue
Block a user