Skip to content

Commit 72391e7

Browse files
authored
Build and deploy docs site via GitHub Actions (#500)
Merge pull request 500
1 parent c17776d commit 72391e7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/docs.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and deploy Documentation site
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
RUBY_VERSION: 2.7
10+
11+
# For control over build environment
12+
DOCS_DEPLOY: true
13+
14+
jobs:
15+
deploy_docs:
16+
runs-on: "ubuntu-latest"
17+
env:
18+
BUNDLE_PATH: "vendor/bundle"
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: ${{ env.RUBY_VERSION }}
24+
bundler-cache: true
25+
- name: Clone target branch
26+
run: |
27+
REMOTE_BRANCH="${REMOTE_BRANCH:-gh-pages}"
28+
REMOTE_REPO="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
29+
30+
echo "Publishing to ${GITHUB_REPOSITORY} on branch ${REMOTE_BRANCH}"
31+
rm -rf docs/_site/
32+
git clone --depth=1 --branch="${REMOTE_BRANCH}" --single-branch --no-checkout \
33+
"${REMOTE_REPO}" docs/_site/
34+
- name: Build site
35+
run: bundle exec jekyll build --source docs --destination docs/_site --verbose --trace
36+
- name: Deploy to GitHub Pages
37+
run: |
38+
SOURCE_COMMIT="$(git log -1 --pretty="%an: %B" "$GITHUB_SHA")"
39+
pushd docs/_site &>/dev/null
40+
: > .nojekyll
41+
42+
git add --all
43+
git -c user.name="${GITHUB_ACTOR}" -c user.email="${GITHUB_ACTOR}@users.noreply.github.com" \
44+
commit --quiet \
45+
--message "Deploy docs from ${GITHUB_SHA}" \
46+
--message "$SOURCE_COMMIT"
47+
git push
48+
49+
popd &>/dev/null

0 commit comments

Comments
 (0)