add toc to Canada is worse #292
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: Deploy hugo site to gh-pages | |
on: [push, pull_request] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
cd: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@main | |
with: | |
submodules: true # Fetch Hugo themes (true OR recursive) | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: Config git | |
run: | | |
git config user.name '${{ github.actor }}' | |
git config user.email '${{ github.actor }}@users.noreply.github.com' | |
- name: Install Hugo | |
run: sudo snap install hugo | |
- name: Setup output | |
id: vars | |
run: | | |
rm -rf public | |
echo 'commit_msg<<EOF' >> $GITHUB_OUTPUT | |
echo "$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
# git worktree <path> <branch> sets <path> as root for <branch> | |
git worktree add public gh-pages | |
- uses: actions/cache@main | |
with: | |
path: /tmp/hugo_cache | |
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-hugomod- | |
# assume all submodules have alreayd been initiated in actions/checkout | |
- name: Update submodules | |
run: | | |
git submodule update --recursive --remote --force | |
output=$(git status --porcelain) | |
if [ -n "$output" ]; then | |
git add . | |
git commit -m "Update submodules" | |
fi | |
- name: Build Hugo | |
run: hugo | |
- name: Add CNAME | |
run: | | |
if [ ! -f public/CNAME ]; then | |
# install yq | |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq | |
yq '.baseUrl' config.yaml | cut -c 9- | sed 's/\/$//' > public/CNAME | |
fi | |
- name: Push submodules update | |
run: | | |
git push | |
- name: Deploy public dir to gh-pages branch | |
if: github.ref_name == github.event.repository.default_branch | |
run: | | |
cd public | |
if [ "`git status -s`" ]; then | |
git add --all | |
commit_msg="${{ steps.vars.outputs.commit_msg }}" | |
commit_msg="${commit_msg//\"/\\\"}" | |
git commit --amend -m "deployed: $commit_msg" | |
fi | |
git push --force |