From 4b6bf833a2f2c78e5d074e5099683d45f6c29cd8 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Wed, 16 Oct 2019 00:17:52 -0400 Subject: [PATCH] switch CI to use GitHub Package Registry --- .github/workflows/gh-pages.yml | 40 +++++++++++++++++++--------------- Dockerfile | 15 ++++++++----- README.md | 2 +- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 4eecad77..957fa302 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -13,29 +13,35 @@ jobs: with: fetch-depth: 1 lfs: false - # pull from custom Hugo Extended image with opinionated changes - # Docker hub: https://hub.docker.com/r/jakejarvis/hugo-custom - # base Dockerfile source: https://go.jarv.is/hugo-dockerfile + + # 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 - uses: docker://jakejarvis/hugo-custom:latest - with: - args: --gc --cleanDestinationDir - # native git commands for speed and simplicity, and because this - # setup is a weird edge case not worth making an action for. - - name: Push to jakejarvis.github.io - shell: bash run: | - # copy Hugo output to somewhere we have permissions + echo ${{ secrets.GITHUB_REGISTRY_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 + 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: | mkdir gh-pages cp -r public/* gh-pages + echo "jarv.is" > gh-pages/CNAME + + # 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 gh-pages - # CNAME file for GitHub Pages custom domain - echo "jarv.is" > CNAME - # set up git git init - git config user.name "Jake Jarvis" - git config user.email "jakejarvis@users.noreply.github.com" - # deploy folder to external *.github.io repository + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" git remote add target 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" diff --git a/Dockerfile b/Dockerfile index e01befb8..6a0e5f3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ -# Custom Hugo Extended fork, pre-built on Docker Hub: -# https://hub.docker.com/r/jakejarvis/hugo-custom -# Base Dockerfile source: https://go.jarv.is/hugo-dockerfile +# Custom Hugo Extended fork, pre-built on GitHub Package Registry: +# https://github.com/jakejarvis/hugo-custom/packages +# https://github.com/jakejarvis/hugo-custom/blob/master/Dockerfile # # Usage: -# docker build -t jarv.is:develop -f Dockerfile . -# docker run -v $(pwd):/src -p 1313:1313 jarv.is:develop +# docker build -t jarv.is:develop -f Dockerfile . +# docker run -v $(pwd):/src -p 1313:1313 jarv.is:develop # ...then open http://localhost:1313 for the live-refresh server. -FROM jakejarvis/hugo-custom:latest +FROM docker.pkg.github.com/jakejarvis/hugo-custom/hugo-custom:latest + +# verify everything's OK +RUN /usr/bin/hugo version # add site source as volume VOLUME /src diff --git a/README.md b/README.md index 7aa5e1dd..c888edf5 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ I keep an ongoing list of [blog post ideas](https://github.com/jakejarvis/jarv.i ## Running a local testing server with Docker -This site runs a [custom version](https://github.com/jakejarvis/hugo-custom) of [Hugo Extended](https://github.com/gohugoio/hugo) with a few (very opinionated) changes. To ensure consistency, the [`Dockerfile`](Dockerfile) in this repository will pull my Hugo [fork](https://github.com/jakejarvis/hugo-custom) (forked from `v0.53-DEV`, [gohugo/hugo@`a28865c`](https://github.com/gohugoio/hugo/tree/a28865cfc3e296cf0ddd0bd6c1368fcdb2154d0f) and pre-built [on Docker Hub](https://hub.docker.com/r/jakejarvis/hugo-custom)) and run a live testing server. +This site runs a [custom version](https://github.com/jakejarvis/hugo-custom) of [Hugo Extended](https://github.com/gohugoio/hugo) with a few (very opinionated) changes. To ensure consistency, the [`Dockerfile`](Dockerfile) in this repository will pull my Hugo [fork](https://github.com/jakejarvis/hugo-custom) (forked from `v0.53-DEV`, [gohugo/hugo@`a28865c`](https://github.com/gohugoio/hugo/tree/a28865cfc3e296cf0ddd0bd6c1368fcdb2154d0f) and pre-built [on GitHub Package Registry](https://github.com/jakejarvis/hugo-custom/packages)) and run a live testing server. Run these commands on the root of this repository: