Skip to content

Update GitHub Pages Records #15

Update GitHub Pages Records

Update GitHub Pages Records #15

name: Update GitHub Pages Records
on:
schedule:
- cron: "0 0 * * 0" # This runs every Sunday at midnight UTC
workflow_dispatch:
jobs:
update_records:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python 3.11
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.11
- name: Install dependencies
run: make install
- name: Run the GitHub Pages script
run: make print-github-delegations
- name: Check for changes
id: check_changes
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
if git diff --exit-code .github_pages; then
echo "no_changes=true" >> "$GITHUB_ENV"
else
echo "no_changes=false" >> "$GITHUB_ENV"
echo "new_domains=$(git diff --exit-code .github_pages | grep '^-[^-]' | sed 's/^-//')" | awk '{ printf "%s\\n", $0 }' >> "$GITHUB_ENV"
fi
- name: Create Pull Request
if: env.no_changes == 'false'
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: ":recycle: Update GitHub Pages Records"
title: ":recycle: Update GitHub Pages Records"
body: |
This PR updates the GitHub Pages records based on the latest configuration.
Auto-generated by GitHub Actions.
branch: update-github-pages
delete-branch: true
base: main
- run: echo ${{ env.new_domains }}
# - name: Send notification to Slack
# if: env.no_changes == 'false'
# uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0
# with:
# payload: |
# {
# "blocks": [
# {
# "type": "section",
# "text": {
# "type": "mrkdwn",
# "text": "The following GitHub Pages delegations have been added:\n\n${{ env.new_domains }}\nMake sure to manually verify new GitHub Pages domains <https://github.com/organizations/ministryofjustice/settings/pages|here> to keep them secure."
# }
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK