docfx: sync from repo-template (gh-pages bootstrap fix)#104
Closed
Chris-Wolfgang wants to merge 1 commit into
Closed
docfx: sync from repo-template (gh-pages bootstrap fix)#104Chris-Wolfgang wants to merge 1 commit into
Chris-Wolfgang wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
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-pagesis missing on the remote. - Track whether a worktree is used and adjust cleanup accordingly.
- Add a
$LASTEXITCODEreset 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 |
Owner
Author
|
Closing — superseded by PR #110, a single comprehensive sync of all files that had drifted from canonical |
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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sync
.github/workflows/docfx.yamlfromrepo-templateto 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-pagesbranch did not yet exist on the remote,$WORK_DIRwas created as a plain directory and the subsequentgit add/diff --cached/commit/pushfailed withfatal: not a git repository. The fix initializes the directory as a git repo ongh-pagesand adds the authenticatedoriginremote, so the existing add/commit/push works on a first-ever deploy. Cleanup also branches betweengit worktree remove(worktree path) andRemove-Item(fresh-repo path).If
gh-pagesalready 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
gh-pagesis unaffected