Skip to content

Auto-enable Pages on first deploy#1445

Open
bmehta001 wants to merge 1 commit into
microsoft:mainfrom
bmehta001:bhamehta/pages-enablement
Open

Auto-enable Pages on first deploy#1445
bmehta001 wants to merge 1 commit into
microsoft:mainfrom
bmehta001:bhamehta/pages-enablement

Conversation

@bmehta001
Copy link
Copy Markdown
Contributor

Summary

  • Pass enablement: true to actions/configure-pages@v5 so 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 main with::

Error: Get Pages site failed. Please verify that the repository has Pages
enabled and configured to build using GitHub Actions, or consider exploring
the `enablement` parameter for this action.
Error: Not Found - https://docs.github.com/rest/pages/pages#get-a-apiname-pages-site

gh api repos/microsoft/cpp_client_telemetry/pages returns 404, which means GitHub Pages has never been provisioned for this repository. actions/configure-pages accepts an enablement parameter that asks the action to create the Pages site on first run; the workflow already grants the pages: write and id-token: write permissions it needs to do so.

Fallback

If the org-level GITHUB_TOKEN restrictions still prevent automatic provisioning, a repository admin only needs to flip Settings -> Pages -> Build and deployment -> Source to GitHub Actions once; subsequent deploys will then succeed without the failure.

Validation

  • YAML parsed cleanly with python -c "import yaml; yaml.safe_load(open(...))"
  • Diff is a two-line addition under the existing actions/configure-pages@v5 step

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>
@bmehta001 bmehta001 requested a review from a team as a code owner May 22, 2026 17:40
@bmehta001 bmehta001 requested a review from Copilot May 26, 2026 23:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: true to actions/configure-pages@v5 in 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this will work? As per the Github docs - this option requires a token other than GITHUB_TOKEN to be provided.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Close this PR and have an admin flip Settings → Pages → Source: GitHub Actions once. One-time, no secret to maintain, cleanest.
  2. Add a PAGES_DEPLOY_TOKEN repo secret with admin:write and pass it via with.token here.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants