ci: Add container image workflow

This commit is contained in:
Antonin Stefanutti 2023-02-14 11:57:37 +01:00 committed by Antonin Stefanutti
parent ec50e7117a
commit 962fa9a65c

75
.github/workflows/image.yml vendored Normal file
View File

@ -0,0 +1,75 @@
name: image
permissions:
packages: write
on:
push:
branches:
- master
tags:
- 'v*'
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'
- 'LICENSE'
pull_request:
branches:
- master
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'
- 'LICENSE'
jobs:
buildx:
if: github.repository_owner == 'astefanutti'
name: buildx
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/decktape
tags: |
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=${{ github.ref_name }}
cache-to: type=gha,scope=${{ github.ref_name }},mode=max
provenance: false