Skip to content

Commit

Permalink
Clone the deploy branch before building
Browse files Browse the repository at this point in the history
As of July 31, 2020, GitHub Pages still fails to deploy if the target
branch contains only one commit (the root commit). By cloning the target
branch before building, we can push the newly built content as a new
commit on top of the existing branch, effectively bypassing this GH
Pages issue.

Also, this preserves the deploy history, though I'm unsure if anyone
really cares.
  • Loading branch information
iBug committed Aug 5, 2020
1 parent e2b3c2a commit e8eb528
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:
gem update bundler --no-document
bundle install --path=vendor/bundle --jobs 4 --retry 3
bundle clean
- name: Clone target branch
run: |
REMOTE_BRANCH="${REMOTE_BRANCH:-gh-pages}"
REMOTE_REPO="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
echo "Publishing to ${GITHUB_REPOSITORY} on branch ${REMOTE_BRANCH}"
git clone --depth=1 --branch="${REMOTE_BRANCH}" --single-branch --no-checkout "${REMOTE_REPO}"
- name: Build site
run: bundle exec jekyll build --source docs --destination docs/_site --verbose --trace
env:
Expand All @@ -43,17 +50,11 @@ jobs:
pushd docs/_site &>/dev/null
: > .nojekyll
REMOTE_REPO="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
REMOTE_BRANCH="${REMOTE_BRANCH:-gh-pages}"
echo "Publishing to ${GITHUB_REPOSITORY} on branch ${REMOTE_BRANCH}"
git init --quiet
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add --all
git commit --quiet \
git -c user.name="${GITHUB_ACTOR}" -c user.email="${GITHUB_ACTOR}@users.noreply.github.com" \
commit --quiet \
--message "Deploy docs from ${GITHUB_SHA}" \
--message "$SOURCE_COMMIT"
git push "$REMOTE_REPO" "+HEAD:${REMOTE_BRANCH}"
git push
popd &>/dev/null

0 comments on commit e8eb528

Please sign in to comment.