docfx: bootstrap gh-pages branch on first deploy#337
Merged
Conversation
When gh-pages did not yet exist on the remote, the deploy step created $WORK_DIR as a plain directory and then ran git add/diff/commit/push against it, which failed with "fatal: not a git repository". Initialize the directory as a git repo on the gh-pages branch and wire up the authenticated origin remote so the existing add/commit/push works. Reproduced in IComparable-Extensions (run 25606117292); workaround was to manually create an orphan gh-pages branch with .nojekyll. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the DocFX GitHub Actions workflow to support the first-ever docs deployment in repositories that do not yet have a gh-pages branch, by creating a valid git repository in the temporary deploy directory so the existing add/commit/push sequence can run successfully.
Changes:
- When
gh-pagesis missing, create$WORK_DIRand initialize it as a git repo ongh-pages. - Add an authenticated
originremote in$WORK_DIRso the later push works in the bootstrap case.
When gh-pages did not yet exist, $WORK_DIR is initialized as a standalone repo, not a worktree of the main checkout. The trailing `git worktree remove $WORK_DIR --force` then fails with a non-zero exit (the directory is not a registered worktree), which fails the step on the first deploy. Track whether a worktree was created with $useWorktree, and at cleanup time either remove the worktree or just delete the directory. Also reset $LASTEXITCODE so any residual cleanup noise does not fail the step. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 9, 2026
Closed
Closed
Closed
Merged
Merged
Closed
Chris-Wolfgang
added a commit
to Chris-Wolfgang/IComparable-Extensions
that referenced
this pull request
May 9, 2026
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>
Chris-Wolfgang
added a commit
to Chris-Wolfgang/DbContextBuilder
that referenced
this pull request
May 9, 2026
## Summary Sync `.github/workflows/docfx.yaml` from `repo-template` to pick up the gh-pages bootstrap fix from [Chris-Wolfgang/repo-template#337](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
Chris-Wolfgang
added a commit
to Chris-Wolfgang/IEnumerable-Extensions
that referenced
this pull request
May 9, 2026
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>
Chris-Wolfgang
added a commit
to Chris-Wolfgang/ETL-FixedWidth
that referenced
this pull request
May 14, 2026
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>
Chris-Wolfgang
added a commit
to Chris-Wolfgang/ETL-Transformers
that referenced
this pull request
May 14, 2026
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>
Chris-Wolfgang
added a commit
to Chris-Wolfgang/ETL-Xml
that referenced
this pull request
May 14, 2026
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>
Chris-Wolfgang
added a commit
to Chris-Wolfgang/ETL-Test-Kit
that referenced
this pull request
May 14, 2026
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>
Chris-Wolfgang
added a commit
to Chris-Wolfgang/ETL-Transformers
that referenced
this pull request
Jun 19, 2026
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>
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
gh-pagesdid not yet exist on the remote,$WORK_DIRwas created as a plain directory and the subsequentgit add/diff --cached/commit/pushcalls all failed withfatal: not a git repository(anderror: unknown option 'cached').$WORK_DIR, initialize it as a git repo on thegh-pagesbranch and add the authenticatedoriginremote, so the existing add/commit/push flow works on the first-ever deploy.Reproduction
Hit in IComparable-Extensions, run 25606117292. Workaround was to manually create an orphan
gh-pagesbranch with.nojekylland re-run.Downstream impact
This is
repo-template— once merged, the change should propagate to all downstream repos via the standardpr.yaml/docfx.yamltemplate sync. Reviewers and downstream maintainers should expect to see this as part of the next sync PR in each consuming repo.Test plan
gh-pagesbranch that the first docs deploy succeeds end-to-end (init → add → commit → push)gh-pagesalready present) are unaffected — the change only runs in theelsebranch