| 1 |
name: Build Docker image |
| 2 |
|
| 3 |
on: |
| 4 |
release: |
| 5 |
types: [published] |
| 6 |
pull_request: |
| 7 |
permissions: |
| 8 |
packages: write |
| 9 |
|
| 10 |
env: |
| 11 |
REGISTRY_IMAGE: ghcr.io/gohugoio/hugo |
| 12 |
|
| 13 |
jobs: |
| 14 |
build: |
| 15 |
runs-on: ubuntu-latest |
| 16 |
|
| 17 |
steps: |
| 18 |
- name: Checkout |
| 19 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 20 |
|
| 21 |
- name: Docker meta |
| 22 |
id: meta |
| 23 |
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 |
| 24 |
with: |
| 25 |
images: ${{ env.REGISTRY_IMAGE }} |
| 26 |
|
| 27 |
- name: Set up Docker Buildx |
| 28 |
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 |
| 29 |
|
| 30 |
- name: Login to GHCR |
| 31 |
# Login is only needed when the image is pushed |
| 32 |
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 |
| 33 |
with: |
| 34 |
registry: ghcr.io |
| 35 |
username: ${{ github.repository_owner }} |
| 36 |
password: ${{ secrets.GITHUB_TOKEN }} |
| 37 |
|
| 38 |
- name: Build and push |
| 39 |
id: build |
| 40 |
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 |
| 41 |
with: |
| 42 |
context: . |
| 43 |
provenance: mode=max |
| 44 |
sbom: true |
| 45 |
push: ${{ github.event_name != 'pull_request' }} |
| 46 |
platforms: linux/amd64,linux/arm64 |
| 47 |
tags: ${{ steps.meta.outputs.tags }} |
| 48 |
labels: ${{ steps.meta.outputs.labels }} |
| 49 |
build-args: HUGO_BUILD_TAGS=extended,withdeploy |