generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 7
72 lines (61 loc) · 2.04 KB
/
publish-docker.yaml
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
name: Publish docker artifacts
on:
push:
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
concurrency: release-docker-${{ github.event.release.tag_name }}
env:
REGISTRY: ghcr.io
defaults:
run:
shell: bash
jobs:
publish-docker:
name: Publish Docker image
strategy:
matrix:
workload: ["controller", "server", "web-hooks", "mtx-job"]
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Prepare repository name
id: prepare-repository-name
run: |
repository=$REGISTRY/${{ github.repository }}/${{ matrix.workload }}
echo "repository=${repository,,}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: extract-metadata
uses: docker/metadata-action@v4
with:
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
images: ${{ steps.prepare-repository-name.outputs.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: build/${{ matrix.workload }}/Dockerfile
platforms: linux/amd64,linux/arm64
context: .
cache-from: |
type=gha,scope=${{ matrix.workload }}-sha-${{ github.sha }}
type=gha,scope=${{ github.ref_name }}-${{ matrix.workload }}
type=gha,scope=${{ github.base_ref || 'main' }}
type=gha,scope=main
cache-to: |
type=gha,scope=${{ matrix.workload }}-sha-${{ github.sha }},mode=max
type=gha,scope=${{ github.ref_name }}-${{ matrix.workload }},mode=max
push: true
tags: ${{ steps.extract-metadata.outputs.tags }}
labels: ${{ steps.extract-metadata.outputs.labels }}