-
Notifications
You must be signed in to change notification settings - Fork 71
82 lines (71 loc) · 2.67 KB
/
container.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Create and publish a container image
on:
push:
# Publish main branch as `develop` image
branches:
- main
# Publish tags as versioned release and `latest` image
tags:
- '*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Need fetch-depth 0 to fetch tags, see https://github.com/actions/checkout/issues/701
with:
fetch-depth: 0
- name: Gather context
id: ctx
run: |
echo is_release=${{ contains(github.ref, 'refs/tags/') }} | tee -a $GITHUB_OUTPUT
echo is_dev=${{ ! contains(github.ref, 'refs/tags/') }} | tee -a $GITHUB_OUTPUT
echo version=$(git describe --always --tags) | tee -a $GITHUB_OUTPUT
# QEMU is used to set up VMs for building non-x86_64 images.
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm,arm64"
# This is required to build multi-arch images.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Configure to use `latest` and the PEP440 version from a tag name for
# releases, and `develop` for non-release main builds.
tags: |
type=pep440,pattern={{ version }},enable=${{ steps.ctx.outputs.is_release }}
type=raw,value=latest,enable=${{ steps.ctx.outputs.is_release }}
type=raw,value=develop,enable=${{ steps.ctx.outputs.is_dev }}
labels: |
org.opencontainers.image.authors=opensource@aiven.io
org.opencontainers.image.url=https://karapace.io
org.opencontainers.image.documentation=https://github.com/Aiven-Open/karapace/
org.opencontainers.image.vendor=Aiven
org.opencontainers.image.licenses=Apache-2.0
- uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
KARAPACE_VERSION=${{ steps.ctx.outputs.version }}
file: container/Dockerfile
platforms: "linux/amd64,linux/arm64"