Skip to content

Build/publish image

Build/publish image #2

name: Build/publish image
on:
push:
branches:
- main
paths:
- "Dockerfile"
workflow_dispatch:
env:
BASE_NAME: ${{ github.repository }}
jobs:
buildx:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run script
id: get-version
shell: bash
run: bash "${GITHUB_WORKSPACE}/scripts/get-version.sh"
- name: Login to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ env.BASE_NAME }}:latest
ghcr.io/${{ env.BASE_NAME }}:${{ steps.get-version.outputs.LATEST_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64,linux/arm/v7