Skip to content

Commit 8537dff

Browse files
committed
Auto merge of #12834 - dvdhrm:pr/contrib, r=weihanglo
ci/contrib: do not fail on missing gh-pages The current contrib deploy-hook fails if there is no `gh-pages` branch. Change the CI order to disregard the old `gh-pages` branch first. The `contrib` deploy-hook always creates a fresh `gh-pages` commit and pushes it out. However, currently it relies on the old `gh-pages` branch to exist, since it does not ignore errors when pruning it. Fortunately, the code always creates a new orphan branch, since it does not want to keep history for deployments. Therefore, we can simply use: `git worktree --orphan -B <branch> <path>` This will ensure to always create an orphan branch named `<branch>`, and override an existing branch if it exists (see `-b` vs `-B`). Hence, there is no need for us to prune the old branch, anymore. Since we will recreate the branch on every push, we have to explicitly specify the remote to push to. We no longer set up branch tracking. Note that running github-actions in a private fork is quite useful to avoid constantly pushing changes to a PR and triggering notifications. Unfortunately, private forks on github do not automatically clone the gh-pages branch. This PR fixes annoying CI failures when updating the master branch on private forks, since github does not automatically clone the gh-pages branch.
2 parents ff768b4 + 1d26183 commit 8537dff

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

.github/workflows/contrib.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ jobs:
2525
run: |
2626
cd src/doc/contrib
2727
mdbook build
28-
git worktree add gh-pages gh-pages
28+
# Override previous ref to avoid keeping history.
29+
git worktree add --orphan -B gh-pages gh-pages
2930
git config user.name "Deploy from CI"
3031
git config user.email ""
3132
cd gh-pages
32-
# Delete the ref to avoid keeping history.
33-
git update-ref -d refs/heads/gh-pages
34-
rm -rf contrib
3533
mv ../book contrib
3634
git add contrib
3735
git commit -m "Deploy $GITHUB_SHA to gh-pages"
38-
git push --force
36+
git push origin +gh-pages

0 commit comments

Comments
 (0)