mirror of
https://github.com/jakejarvis/hugo-docker.git
synced 2025-04-26 07:15:23 -04:00
93 lines
2.9 KiB
YAML
93 lines
2.9 KiB
YAML
name: Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
merge_group:
|
|
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:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
if: ${{ github.ref == 'refs/heads/master' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: jakejarvis
|
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
if: ${{ github.ref == 'refs/heads/master' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GHCR_PAT }}
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Parse Hugo version
|
|
id: parse_version
|
|
run: |
|
|
HUGO_VERSION="$(grep -oP '(?<=^ARG HUGO_VERSION=).+$' Dockerfile)"
|
|
echo "HUGO_VERSION=$HUGO_VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push
|
|
id: build
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.ref == 'refs/heads/master' }}
|
|
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-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Image 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
|