Auto-enable Pages on first deploy#1445
Conversation
The GitHub Pages site has never been provisioned for this repository, so the post-merge deploy job in deploy-docs-pages.yml fails when actions/configure-pages@v5 looks up the site and gets a 404 (HTTP Not Found from the Pages API). Pass `enablement: true` to actions/configure-pages so the action provisions the Pages site on first run instead of erroring out. The workflow already grants the `pages: write` and `id-token: write` permissions that the action needs to do this. If the org-level GITHUB_TOKEN restrictions still prevent automatic enablement, a repository admin only needs to flip Settings -> Pages -> Build and deployment -> Source to `GitHub Actions` once; subsequent deploys will then succeed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub Pages deploy workflow to automatically provision/enable the repository’s Pages site on the first successful deployment, addressing current Get Pages site failed / 404 failures when Pages hasn’t been configured yet.
Changes:
- Pass
enablement: truetoactions/configure-pages@v5in the deploy job so the action can auto-enable Pages on first run.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Configure GitHub Pages | ||
| uses: actions/configure-pages@v5 | ||
| with: | ||
| enablement: true |
There was a problem hiding this comment.
Are you sure this will work? As per the Github docs - this option requires a token other than GITHUB_TOKEN to be provided.
There was a problem hiding this comment.
You are correct — I misread the docs. actions/configure-pages requires administration:write (PAT or GitHub App) to provision the Pages site; with only GITHUB_TOKEN, enablement: true will still 403. So this two-line diff is effectively a no-op.
Two real paths:
- Close this PR and have an admin flip Settings → Pages → Source: GitHub Actions once. One-time, no secret to maintain, cleanest.
- Add a
PAGES_DEPLOY_TOKENrepo secret with admin:write and pass it viawith.tokenhere.
I'd lean (1) unless we expect this workflow to be cloned to new repos. Which would you prefer? Happy to push (2) or close in favor of (1).
Summary
enablement: truetoactions/configure-pages@v5so the Deploy documentation to GitHub Pages workflow provisions the Pages site on first run.Why
The post-merge deploy job has been failing on every push to
mainwith::gh api repos/microsoft/cpp_client_telemetry/pagesreturns 404, which means GitHub Pages has never been provisioned for this repository.actions/configure-pagesaccepts anenablementparameter that asks the action to create the Pages site on first run; the workflow already grants thepages: writeandid-token: writepermissions it needs to do so.Fallback
If the org-level
GITHUB_TOKENrestrictions still prevent automatic provisioning, a repository admin only needs to flip Settings -> Pages -> Build and deployment -> Source toGitHub Actionsonce; subsequent deploys will then succeed without the failure.Validation
python -c "import yaml; yaml.safe_load(open(...))"actions/configure-pages@v5step