Build image and push #314
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 | |
on: | |
# NOTE: Runs on branch or tag creation. | |
create: | |
branches: | |
- main | |
schedule: | |
# Run every Sunday at 1am o'clock. | |
- cron: '0 1 * * 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: | |
build-image-and-push: | |
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 || 'CURRENT_TAG_OR_BRANCH latest' }} | |
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.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} |