1
0
mirror of synced 2025-12-19 09:57:42 -05:00

Update branch protections workflow for clarity (#52312)

This commit is contained in:
Evan Bonsignori
2024-09-16 15:43:35 -07:00
committed by GitHub
parent 05e546e11f
commit 381176e22d
2 changed files with 21 additions and 4 deletions

View File

@@ -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 }}

View File

@@ -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