Chores — GitHub Pages Configuration #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Chores — GitHub Pages Configuration | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # daily at 00:00 UTC | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: read | |
| pages: read | |
| issues: write | |
| jobs: | |
| pages-check: | |
| name: Check GitHub Pages Configuration | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | |
| - name: Install jq (if missing) | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y jq | |
| - name: Check Pages configuration | |
| id: pages_check | |
| continue-on-error: true | |
| run: | | |
| set +e | |
| # Get Pages info from GitHub API | |
| PAGES_INFO=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pages") | |
| # Check if Pages is enabled | |
| if echo "$PAGES_INFO" | jq -e '.html_url' > /dev/null 2>&1; then | |
| echo "✅ GitHub Pages is configured" | |
| echo "exit_code=0" >> $GITHUB_OUTPUT | |
| exit 0 | |
| else | |
| echo "❌ GitHub Pages is not configured or not accessible" | |
| echo "exit_code=1" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| - name: Create GitHub issue on failure | |
| if: steps.pages_check.outputs.exit_code != '0' | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const label = 'chores/pages-check'; | |
| const title = `[chores] GitHub Pages misconfigured for ${owner}/${repo}`; | |
| const body = `The scheduled GitHub Pages configuration check failed for **${owner}/${repo}**.\n\n` + | |
| `Please verify the Pages source is configured correctly in repository settings.\n\n` + | |
| `Workflow run: ${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`; | |
| // Check for existing open issues with the label | |
| const existing = await github.rest.issues.listForRepo({ owner, repo, state: 'open', labels: label }); | |
| if (existing.data && existing.data.length > 0) { | |
| console.log('An open issue for Pages check already exists; skipping creation.'); | |
| } else { | |
| // Create the issue | |
| await github.rest.issues.create({ owner, repo, title, body, labels: [label] }); | |
| console.log('Created issue:', title); | |
| } | |
| - name: Final status | |
| run: | | |
| if [ "${{ steps.pages_check.outputs.exit_code }}" = "0" ]; then | |
| echo "Pages check: OK" | |
| else | |
| echo "Pages check: FAILURE — issue created or already exists" | |
| exit 1 | |
| fi |