Build image and push #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build image and push | |
run-name: Build image and push | |
on: | |
# NOTE: Runs on version tag creation. | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-[0-9]+' | |
# Runs when a new version was prepared. | |
repository_dispatch: | |
types: | |
- prepare-pre-release-event | |
- prepare-release-event | |
# Run every Sunday at 2am o'clock. | |
schedule: | |
- cron: '0 2 * * 0' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
architecture: | |
default: all | |
description: Architecture name to build for. | |
type: choice | |
options: | |
- all | |
- arm-64 | |
- x86-64 | |
build-args: | |
description: List of build-time variables. | |
use-cache: | |
description: Use cache when building the image. | |
default: true | |
type: boolean | |
tags: | |
description: Image tags to use for registering. | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.event.repository.name }} | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: thaibault/build-image-push-action@main | |
with: | |
name: ${{ env.IMAGE_NAME }} | |
tags: | | |
${{ | |
inputs.tags || | |
format( | |
'{0} latest', | |
github.event.client_payload.version || | |
github.head_ref || | |
github.ref_name | |
) | |
}} | |
architecture: ${{ inputs.architecture || 'all' }} | |
build-args: | | |
BRANCH_NAME=${{ github.ref_name || 'main' }} | |
${{ inputs.build-args }} | |
cache-key: ${{ runner.os }}-buildx-layer-${{ github.sha }} | |
cache-restore-keys: ${{ runner.os }}-buildx-layer- | |
use-cache: ${{ inputs.use-cache && github.event_name != 'schedule' }} | |
alternate-registry: docker.io | |
alternate-username: ${{ secrets.DOCKERHUB_USERNAME }} | |
alternate-password: ${{ secrets.DOCKERHUB_TOKEN }} | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} |