Skip to content

check, build, deploy site #5320

check, build, deploy site

check, build, deploy site #5320

name: check, build, deploy site
on:
push:
branches: main
pull_request: []
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
build-website:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout the Repository
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
- name: Install GitHub Pages, Bundler, and kramdown gems
run: |
gem install bundler:2.4.22 yaml-lint
- name: Set up caching for Bundler
uses: actions/cache@v2
with:
path: .vendor/bundle
key: gems-${{ hashFiles('**/Gemfile') }}
restore-keys: |
gems-
- name: Install & Update Ruby Gems
run: |
bundle config path .vendor/bundle
bundle install --jobs 4 --retry 3
bundle update
- name: Lint _config.yml with yaml-lint
run: |
yaml-lint _config.yml
- name: Lint pages and blog posts
run: |
yaml-lint -q -n $(find _posts -regex ".*.md\|.*html") &&\
yaml-lint -q -n $(find pages -regex ".*.md\|.*html")
- name: Build site
run: make site
- name: Checkout github pages
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/gh-pages'}}
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages
- name: Deploy
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/gh-pages'}}
run: |
# clean up gh-pages
cd gh-pages
git rm -rf . # remove all previous files
cd ..
# copy everything from _site to the gh-pages folder
cp -r _site/* gh-pages
# move into gh-pages, add, commit, and push
cd gh-pages
# setup git
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
if [ -z "$(git status --porcelain)" ]; then
echo "Nothing to commit"
exit 0
fi
git add -A .
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})"
git push --force origin gh-pages
# return
cd ..