-
Notifications
You must be signed in to change notification settings - Fork 781
48 lines (43 loc) · 1.55 KB
/
github-pages.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: GitHub Pages
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy
if: ${{ github.repository == 'qunitjs/qunit' }} # skip noisy cron on forks
runs-on: ubuntu-20.04
env:
DEPLOY_DIR: docs/_site/
DEPLOY_BRANCH: gh-pages
steps:
- uses: actions/checkout@v4
- name: Prepare branch
run: |
mkdir "${DEPLOY_DIR}"
cd "${DEPLOY_DIR}"
# Clone and checkout existing branch, or initialise with a new and empty branch
git clone --depth 5 --branch "${DEPLOY_BRANCH}" "https://github.com/${GITHUB_REPOSITORY}.git" . || git init -b "${DEPLOY_BRANCH}"
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
# If your site is in a subdirectory
working-directory: ./docs/
- name: Jekyll build
# If your site is in a subdirectory
working-directory: ./docs/
run: bundle exec jekyll build
- name: Push to branch
# Inspired by https://github.com/helaili/jekyll-action/blob/2.2.0/entrypoint.sh
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
cd "${DEPLOY_DIR}"
touch .nojekyll
git config user.name "${GITHUB_ACTOR}" && \
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
git add . && \
git commit --allow-empty -m "Build commit ${GITHUB_SHA}" && \
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:${DEPLOY_BRANCH}"