Merge pull request #38 from restic/blog-rs-0130 #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Checks | |
on: | |
# run tests on push to master, but not when other branches are pushed to | |
push: | |
branches: | |
- master | |
# run tests for pull requests to master | |
pull_request: | |
branches: | |
- master | |
# debug GitHub Actions locally with 'act': | |
# https://michaelheap.com/testing-github-actions-with-act/ | |
jobs: | |
build-and-check: | |
runs-on: ubuntu-latest | |
steps: | |
# Must be the extended version of Hugo to support SCSS. | |
- name: Install Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: latest | |
extended: true | |
- name: Install muffet | |
run: | | |
mkdir $HOME/bin | |
curl -L https://github.com/raviqqe/muffet/releases/download/v2.9.3/muffet_linux_amd64.tar.gz | tar zx -C $HOME/bin | |
echo "$HOME/bin" >> $GITHUB_PATH | |
- name: Check out website | |
uses: actions/checkout@v1 | |
- name: Build website | |
run: | | |
hugo --destination public-compare --templateMetrics --templateMetricsHints | |
- name: Check for differences | |
run: diff -aur public public-compare | |
- name: Check links | |
run: | | |
# Start Hugo web server in the background to serve the website for link checking. | |
# For some reason we need this --baseURL argument in place, otherwise muffet will give a lot of | |
# "dial tcp4 127.0.1.1:1313: connect: connection refused" and not be able to scrape the website. | |
hugo server --baseURL http://127.0.0.1:1313/ --disableBrowserError --disableLiveReload & | |
# Give Hugo some time to start up before scraping. | |
sleep 2 | |
# Check for dead links and similar problems, with generous timeout due to e.g. MIT PGP server. | |
muffet --timeout=90 --ignore-fragments --buffer-size=8192 http://127.0.0.1:1313 | |
# kill hugo again | |
kill %1 |