mirror of
https://github.com/hugomods/docker.git
synced 2025-04-26 13:10:48 +03:00
feat: add nightly tag (#113)
* feat: add nightly tag * feat: build non-root image for nightly tag * fix: correct nightly build tags
This commit is contained in:
parent
796fb87fbc
commit
fcb270f3d6
3 changed files with 92 additions and 3 deletions
92
.github/workflows/build-nightly.yml
vendored
Normal file
92
.github/workflows/build-nightly.yml
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
name: build-nightly
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/build-nightly.yml'
|
||||||
|
- 'docker/hugo/**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
PLATFORMS: linux/amd64,linux/arm64
|
||||||
|
IMAGE_OWNER: hugomods
|
||||||
|
IMAGE_NAME: hugo
|
||||||
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
user: ['root', 'hugo'] # default container user.
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout the main repository.
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Checkout the Hugo repository for building.
|
||||||
|
- name: Checkout Hugo repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: gohugoio/hugo
|
||||||
|
path: ./docker/hugo/src
|
||||||
|
|
||||||
|
- name: Build meta
|
||||||
|
id: build_meta
|
||||||
|
run: |
|
||||||
|
echo "date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
|
||||||
|
cd ./docker/hugo/src && echo "hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: LDFLAGS
|
||||||
|
id: ldflags
|
||||||
|
run: |
|
||||||
|
HASH='github.com/gohugoio/hugo/common/hugo.commitHash=${{ steps.build_meta.outputs.hash }}'
|
||||||
|
BUILD_DATE='github.com/gohugoio/hugo/common/hugo.buildDate=${{ steps.build_meta.outputs.date }}'
|
||||||
|
VENDOR='github.com/gohugoio/hugo/common/hugo.vendorInfo=hugomods'
|
||||||
|
echo "-X '$HASH' -X '$BUILD_DATE' -X '$VENDOR'"
|
||||||
|
echo "flags=-X '$HASH' -X '$BUILD_DATE' -X '$VENDOR'">> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
with:
|
||||||
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: ${{ env.BRANCH_NAME == 'main' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
if: ${{ env.BRANCH_NAME == 'main' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ env.IMAGE_OWNER }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
push: ${{ env.BRANCH_NAME == 'main' }}
|
||||||
|
context: docker/hugo
|
||||||
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
file: docker/hugo/Dockerfile-ci
|
||||||
|
tags: |
|
||||||
|
hugomods/hugo:nightly${{ matrix.user == 'hugo' && '-non-root' || '' }}
|
||||||
|
ghcr.io/hugomods/hugo:nightly${{ matrix.user == 'hugo' && '-non-root' || '' }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
build-args: |
|
||||||
|
LDFLAGS=${{ steps.ldflags.outputs.flags }}
|
||||||
|
BUILD_TAGS=extended,withdeploy
|
||||||
|
USER=${{ matrix.user }}
|
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -290,7 +290,6 @@ jobs:
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
build-args: |
|
build-args: |
|
||||||
LDFLAGS=${{ steps.ldflags.outputs.flags }}
|
LDFLAGS=${{ steps.ldflags.outputs.flags }}
|
||||||
HUGO_VERSION=v${{ steps.release.outputs.version }}
|
|
||||||
BUILD_TAGS=${{ matrix.build_tags }}
|
BUILD_TAGS=${{ matrix.build_tags }}
|
||||||
USER=${{ matrix.user }}
|
USER=${{ matrix.user }}
|
||||||
|
|
||||||
|
@ -504,6 +503,5 @@ jobs:
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
build-args: |
|
build-args: |
|
||||||
LDFLAGS=${{ steps.ldflags.outputs.flags }}
|
LDFLAGS=${{ steps.ldflags.outputs.flags }}
|
||||||
HUGO_VERSION=v${{ steps.release.outputs.version }}
|
|
||||||
BUILD_TAGS=${{ matrix.build_tags }}
|
BUILD_TAGS=${{ matrix.build_tags }}
|
||||||
USER=${{ matrix.user }}
|
USER=${{ matrix.user }}
|
||||||
|
|
|
@ -7,7 +7,6 @@ RUN apk add clang lld
|
||||||
COPY --from=xx / /
|
COPY --from=xx / /
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG HUGO_VERSION
|
|
||||||
ARG BUILD_TAGS
|
ARG BUILD_TAGS
|
||||||
ARG GOPROXY
|
ARG GOPROXY
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue