mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 08:18:28 -04:00
64 lines
2.6 KiB
YAML
64 lines
2.6 KiB
YAML
name: GitHub Pages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@master
|
|
with:
|
|
fetch-depth: 1
|
|
lfs: false
|
|
|
|
# Pull from custom Hugo Extended image with opinionated changes:
|
|
# https://github.com/jakejarvis/hugo-custom/packages
|
|
# https://github.com/jakejarvis/hugo-custom/blob/master/Dockerfile
|
|
# Can't use native `uses: docker://` syntax for GitHub Package Registry...
|
|
- name: Build Hugo
|
|
run: |
|
|
echo ${{ secrets.GITHUB_ACCESS_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
|
|
docker run -v $GITHUB_WORKSPACE:/src docker.pkg.github.com/jakejarvis/hugo-custom/hugo-custom:latest --gc --cleanDestinationDir --verbose
|
|
docker logout docker.pkg.github.com
|
|
|
|
# Copy built site to a directory where we have permissions, and
|
|
# add a CNAME file for a custom domain (jarv.is).
|
|
- name: Prepare for GitHub Pages
|
|
run: |
|
|
cp -r $GITHUB_WORKSPACE/public $HOME/gh-pages
|
|
echo "jarv.is" > $HOME/gh-pages/CNAME
|
|
|
|
# Put a bow on top of Hugo's automatic image processing by using
|
|
# pngquant and jpegoptim to optimize/compress images in posts,
|
|
# just a little lossily (is that a word?)
|
|
#
|
|
# TODO: Find a way to cache the results, this takes about 4 minutes
|
|
# each build -- not ideal. Maybe use @sindresorhus/imagemin.
|
|
- name: Optimize processed images
|
|
run: |
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends jpegoptim pngquant optipng
|
|
cd $HOME/gh-pages/notes
|
|
find . -iname "*.jp*" -print0 | xargs -0 jpegoptim --max=80 --strip-all
|
|
find . -iname "*.png" -print0 | xargs -0 pngquant --quality=50-70 --speed 3 --ext=.png --force
|
|
find . -iname "*.png" -print0 | xargs -0 optipng -o3 -force -strip all -quiet --
|
|
# Ignore errors - override pipefail
|
|
shell: bash {0}
|
|
|
|
# Initialize a sub-repository in the new gh-pages directory and
|
|
# add jakejarvis/jakejarvis.github.io as a remote.
|
|
# Using native git commands for speed and simplicity, and because
|
|
# this setup is a weird edge case not worth making an action for.
|
|
- name: Deploy to jakejarvis.github.io
|
|
run: |
|
|
cd $HOME/gh-pages
|
|
git init
|
|
git config user.name "$GITHUB_ACTOR"
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
git remote add origin https://${{ secrets.GITHUB_ACCESS_TOKEN }}@github.com/jakejarvis/jakejarvis.github.io.git
|
|
git add -A
|
|
git commit -m "GitHub Pages deploy from $GITHUB_REPOSITORY@$GITHUB_SHA"
|
|
git push --force origin master
|