91 lines
2.9 KiB
YAML
91 lines
2.9 KiB
YAML
name: Build Container
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
prerelease:
|
|
type: boolean
|
|
description: Whether to create a prerelease tag
|
|
default: false
|
|
dry-run:
|
|
type: boolean
|
|
description: Whether to dry run the build and push
|
|
default: false
|
|
registry:
|
|
type: string
|
|
description: The registry to use
|
|
required: true
|
|
registry-user:
|
|
type: string
|
|
description: The username to use for the registry
|
|
required: true
|
|
registry-password:
|
|
type: string
|
|
description: The password to use for the registry
|
|
required: true
|
|
repo-name:
|
|
type: string
|
|
description: The name of the repository
|
|
required: true
|
|
tag:
|
|
type: string
|
|
description: The tag to use for the repository
|
|
required: true
|
|
context:
|
|
type: string
|
|
description: The context to use for the build
|
|
default: .
|
|
dockerfile:
|
|
type: string
|
|
description: The Dockerfile to use for the build
|
|
default: Dockerfile
|
|
|
|
jobs:
|
|
build_and_push:
|
|
name: Build and push
|
|
strategy:
|
|
matrix:
|
|
# Prepared for future multi-arch support in the future, as soon as ACT has support for dynamic matrixes.
|
|
arch: [amd64]
|
|
needs:
|
|
- test
|
|
runs-on:
|
|
- ubuntu-latest
|
|
- linux_${{ matrix.arch }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
|
- uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ${{ inputs.registry }}
|
|
username: ${{ inputs.registry-user }}
|
|
password: ${{ inputs.registry-password }}
|
|
- uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
with:
|
|
context: ${{ inputs.context }}
|
|
file: ${{ inputs.dockerfile }}
|
|
platforms: linux/${{ matrix.arch }}
|
|
push: ${{ !inputs.dry-run }}
|
|
provenance: false
|
|
tags: |
|
|
${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }}-${{ matrix.arch }}
|
|
|
|
create_manifest:
|
|
name: Create manifest
|
|
if: ${{ !inputs.dry-run }}
|
|
needs:
|
|
- build_and_push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ${{ inputs.registry }}
|
|
username: ${{ inputs.registry-user }}
|
|
password: ${{ inputs.registry-password }}
|
|
- run: |
|
|
docker manifest create ${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }} \
|
|
${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }}-amd64
|
|
|
|
docker manifest push ${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }}
|