88 lines
2.4 KiB
YAML
88 lines
2.4 KiB
YAML
name: build container
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
registry:
|
|
required: true
|
|
type: string
|
|
description: "registry to upload the container to"
|
|
image-name:
|
|
required: true
|
|
type: string
|
|
description: "image name of the container"
|
|
context:
|
|
required: false
|
|
type: string
|
|
description: "context location for the build"
|
|
default: "."
|
|
dockerfile:
|
|
required: false
|
|
type: string
|
|
description: "location of the dockerfile"
|
|
default: "Dockerfile"
|
|
platforms:
|
|
required: false
|
|
type: string
|
|
description: "platforms to build for"
|
|
default: "linux/amd64"
|
|
|
|
secrets:
|
|
cr-username:
|
|
required: true
|
|
description: "registry username"
|
|
cr-password:
|
|
required: true
|
|
description: "registry password"
|
|
|
|
jobs:
|
|
build-container:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: setup qemu
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: setup docker buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: get container metadata
|
|
uses: docker/metadata-action@v4
|
|
id: metadata
|
|
with:
|
|
images: ${{ inputs.registry }}/${{ inputs.image-name }}
|
|
flavor: |
|
|
latest=auto
|
|
prefix=
|
|
suffix=
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=sha
|
|
|
|
- name: login to container registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ inputs.registry }}
|
|
username: ${{ secrets.cr-username }}
|
|
password: ${{ secrets.cr-password }}
|
|
|
|
- name: build and push docker image @${{ inputs.platforms }}
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
push: ${{ gitea.event_name != 'pull_request' }}
|
|
platforms: ${{ inputs.platforms }}
|
|
context: ${{ inputs.context }}
|
|
file: ${{ inputs.dockerfile }}
|
|
provenance: false
|
|
tags: ${{ steps.metadata.outputs.tags }}
|
|
labels: ${{ steps.metadata.outputs.labels }}
|
|
build-args: |
|
|
BUILD_VERSION=${{ steps.metadata.outputs.version }}
|
|
BUILD_COMMIT=${{ gitea.sha }}
|