You've already forked hugo-docker
mirror of
https://github.com/jakejarvis/hugo-docker.git
synced 2025-06-27 16:15:40 -04:00
automatically build & push on new Hugo releases
This commit is contained in:
88
.github/workflows/build.yml
vendored
88
.github/workflows/build.yml
vendored
@ -4,10 +4,20 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
tags:
|
pull_request:
|
||||||
- 'v*'
|
branches:
|
||||||
|
- master
|
||||||
|
merge_group:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
HUB_IMAGE: jakejarvis/hugo-extended
|
||||||
|
GHCR_IMAGE: ghcr.io/jakejarvis/hugo-extended
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -15,33 +25,31 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
- name: Prepare tags
|
fetch-depth: 0
|
||||||
id: tag
|
|
||||||
env:
|
|
||||||
HUB_IMAGE: jakejarvis/hugo-extended
|
|
||||||
GHCR_IMAGE: ghcr.io/jakejarvis/hugo-extended
|
|
||||||
run: |
|
|
||||||
TAGS="${HUB_IMAGE}:latest,${GHCR_IMAGE}:latest"
|
|
||||||
|
|
||||||
# If triggered by a new tag, add a version tag to the image
|
|
||||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/v}
|
|
||||||
TAGS="$TAGS,${HUB_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set output parameters
|
|
||||||
echo ::set-output name=tags::${TAGS}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
with:
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: ${{ github.ref == 'refs/heads/master' }}
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: jakejarvis
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
if: ${{ github.ref == 'refs/heads/master' }}
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GHCR_PAT }}
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- name: Cache Docker layers
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
@ -50,33 +58,35 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-buildx-
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Parse Hugo version
|
||||||
if: github.event_name != 'pull_request'
|
id: parse_version
|
||||||
uses: docker/login-action@v2
|
run: |
|
||||||
with:
|
HUGO_VERSION="$(grep -oP '(?<=^ARG HUGO_VERSION=).+$' Dockerfile)"
|
||||||
username: jakejarvis
|
echo "HUGO_VERSION=$HUGO_VERSION" >> $GITHUB_OUTPUT
|
||||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GHCR_PAT }}
|
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
context: ./
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ github.ref == 'refs/heads/master' }}
|
||||||
tags: ${{ steps.tag.outputs.tags }}
|
tags: "${{ env.HUB_IMAGE }}:latest,${{ env.GHCR_IMAGE }}:latest,${{ env.HUB_IMAGE }}:${{ steps.parse_version.outputs.HUGO_VERSION }},${{ env.GHCR_IMAGE }}:${{ steps.parse_version.outputs.HUGO_VERSION }}"
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: echo ${{ steps.build.outputs.digest }}
|
run: echo ${{ steps.build.outputs.digest }}
|
||||||
|
|
||||||
|
- name: Update hub description
|
||||||
|
uses: peter-evans/dockerhub-description@v3
|
||||||
|
if: ${{ github.ref == 'refs/heads/master' }}
|
||||||
|
with:
|
||||||
|
username: jakejarvis
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
repository: ${{ env.HUB_IMAGE }}
|
||||||
|
short-description: "✏️ Hugo Extended for x64 and ARM64 with PostCSS, Babel, Pandoc, and more baked in."
|
||||||
|
readme-filepath: ./README.md
|
||||||
|
enable-url-completion: true
|
||||||
|
@ -8,7 +8,7 @@ ARG HUGO_BUILD_TAGS=extended
|
|||||||
# ---
|
# ---
|
||||||
|
|
||||||
# Hugo >= v0.81.0 requires Go 1.16+ to build
|
# Hugo >= v0.81.0 requires Go 1.16+ to build
|
||||||
FROM golang:1.19-alpine3.17 AS build
|
FROM golang:1.20-alpine3.17 AS build
|
||||||
|
|
||||||
# renew global args from above
|
# renew global args from above
|
||||||
# https://docs.docker.com/engine/reference/builder/#scope
|
# https://docs.docker.com/engine/reference/builder/#scope
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
"extends": [
|
"extends": [
|
||||||
"config:base"
|
"config:base"
|
||||||
],
|
],
|
||||||
"automerge": false,
|
"automerge": true,
|
||||||
|
"platformAutomerge": true,
|
||||||
"regexManagers": [
|
"regexManagers": [
|
||||||
{
|
{
|
||||||
"fileMatch": [
|
"fileMatch": [
|
||||||
|
Reference in New Issue
Block a user