generated from vsoch/notes-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (41 loc) · 1.18 KB
/
build.yml
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
name: Build
on:
push:
branches-ignore:
- gh-pages
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: main
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Build site
run: |
bundle install
bundle exec jekyll build
- name: Deploy
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
run: |
set -xo pipefail
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b gh-pages || git checkout "${BRANCH}"
git branch
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git status
ls -Q | grep -v _site | xargs rm -rf
mv _site/* .
rm -rf _site
rm -rf .jekyll-cache
[[ -n "$(git status --porcelain)" ]] || exit 0
git add .
git commit -m "Build $(git rev-parse source | grep -o '^.\{10\}')"
git push origin "${BRANCH}" --force