Skip to content

docfx: sync from repo-template (gh-pages bootstrap fix)#104

Closed
Chris-Wolfgang wants to merge 1 commit into
mainfrom
fix/docfx-bootstrap-gh-pages
Closed

docfx: sync from repo-template (gh-pages bootstrap fix)#104
Chris-Wolfgang wants to merge 1 commit into
mainfrom
fix/docfx-bootstrap-gh-pages

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

Sync .github/workflows/docfx.yaml from repo-template to pick up the gh-pages bootstrap fix from Chris-Wolfgang/repo-template#337.

What changed

The "Deploy docs to GitHub Pages" step had a latent bug: when the gh-pages branch did not yet exist on the remote, $WORK_DIR was created as a plain directory and the subsequent git add / diff --cached / commit / push failed with fatal: not a git repository. The fix initializes the directory as a git repo on gh-pages and adds the authenticated origin remote, so the existing add/commit/push works on a first-ever deploy. Cleanup also branches between git worktree remove (worktree path) and Remove-Item (fresh-repo path).

If gh-pages already exists in this repo (the common case), this change is a no-op at runtime — the bootstrap branch is only taken on a fresh repo.

Test plan

  • Workflow YAML lints / next docs deploy succeeds
  • (Optional) verify gh-pages is unaffected

Sync .github/workflows/docfx.yaml from canonical repo-template to pick up the bootstrap fix from Chris-Wolfgang/repo-template#337.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 9, 2026 17:17

Copilot AI left a comment

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Syncs the DocFX GitHub Actions workflow with the upstream repo template to fix first-time gh-pages deployments (when the branch doesn’t yet exist).

Changes:

  • Add a “fresh gh-pages repo” bootstrap path when gh-pages is missing on the remote.
  • Track whether a worktree is used and adjust cleanup accordingly.
  • Add a $LASTEXITCODE reset after cleanup to avoid cleanup failures failing the step.

@@ -335,7 +335,8 @@ jobs:

# Set up gh-pages worktree (or start fresh if the branch does not exist yet)
$branchExists = git ls-remote --heads origin gh-pages
Comment on lines +351 to +352
git -C $WORK_DIR init --initial-branch=gh-pages
git -C $WORK_DIR remote add origin "https://x-access-token:$($env:GITHUB_TOKEN)@github.com/$($env:GITHUB_REPOSITORY).git"
Comment on lines +422 to +428
if ($useWorktree) {
git worktree remove $WORK_DIR --force 2>&1 | Out-Null
} else {
Remove-Item $WORK_DIR -Recurse -Force -ErrorAction SilentlyContinue
}
# Reset $LASTEXITCODE so cleanup noise does not fail the step.
$global:LASTEXITCODE = 0
@Chris-Wolfgang

Copy link
Copy Markdown
Owner Author

Closing — superseded by PR #110, a single comprehensive sync of all files that had drifted from canonical repo-template/main. The piecemeal approach (one PR per file) had fallen behind canonical's continued evolution; consolidating into one PR is cleaner.

Chris-Wolfgang pushed a commit that referenced this pull request May 10, 2026
Bulk sync of all files where Try-Pattern had drifted from canonical
repo-template/main as of today (2026-05-10). Supersedes the 4 in-flight
piecemeal sync PRs (#104, #105, #106, #109), which each covered only a
slice of one file's drift.

Files changed:

- .editorconfig: drop redundant [*.ps1] indent_size = 4 block (global
  [*] already sets indent_size = 4); reword PowerShell comment for
  accuracy.

- .gitattributes: enforce *.ps1 eol=lf (was just text); reword comment
  to clarify BOM-free encoding is .editorconfig's job, not gitattribute's.

- .github/workflows/pr.yaml: dedup the duplicated 'Fetch trusted
  configuration files from main branch' step that was repeated across
  jobs; add Dependabot guard to the Windows job's variant; UTF-8 (no
  BOM) writes for protected config fetches.

- .github/workflows/docfx.yaml: gh-pages bootstrap fix (initialize
  empty repo when gh-pages doesn't exist); try/finally extraheader
  cleanup so the encoded GITHUB_TOKEN never leaks past the deploy
  step; explicit 'exit $deployExitCode' after finally so failed
  deploys actually fail the step (was being silently swallowed); ls-
  remote failure detection so a transient network/auth failure can't
  silently bootstrap over an existing gh-pages branch.

- scripts/Setup-Labels.ps1: add #!/usr/bin/env pwsh shebang.

- scripts/Setup-GitHubPages.ps1: minor sync (small drift).

- docs/README-FORMATTING.md, docs/RELEASE-WORKFLOW-SETUP.md,
  docs/WORKFLOW_SECURITY.md: new from canonical (Try-Pattern's /docs/
  was previously just a placeholder index.html).

Touches several protected files (.editorconfig, .gitattributes,
.github/workflows/*) so the 'Detect .NET Projects' guard will block
auto-merge — maintainer override required.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Chris-Wolfgang Chris-Wolfgang deleted the fix/docfx-bootstrap-gh-pages branch June 27, 2026 21:17
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.

2 participants