Repository navigation
157 lines (130 loc) · 4.15 KB
/
Copy pathdocker-build.yaml
File metadata and controls
157 lines (130 loc) · 4.15 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Docker Image Build
on:
pull_request:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
env:
REGISTRY: swr.eu-de.otc.t-systems.com
PROJECT: metrics-processor
SWR_PROJECT: eu-de
permissions:
contents: read
jobs:
build:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
env:
ORG: stackmon
steps:
- uses: actions/checkout@v7
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.PROJECT }}
tags: |
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v7
with:
context: .
target: metrics-processor
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: false
# Builds from main and manual runs land in the stackmon project (the preprod cluster's pull secret only grants access to it); a release adds a semver tag.
publish-preprod:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
env:
ORG: stackmon
steps:
- uses: actions/checkout@v7
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.PROJECT }}
tags: |
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
env:
SWR_AK: ${{ secrets.SWR_AK }}
SWR_SK: ${{ secrets.SWR_SK }}
run: |
set -euo pipefail
if [ -z "$SWR_AK" ] || [ -z "$SWR_SK" ]; then
echo "The SWR_AK and SWR_SK repository secrets must be set" >&2
exit 1
fi
login_key="$(printf '%s' "$SWR_AK" | openssl dgst -sha256 -hmac "$SWR_SK" | awk '{print $NF}')"
if [[ ! "$login_key" =~ ^[0-9a-f]{64}$ ]]; then
echo "Cannot derive the SWR login key from the AK/SK pair" >&2
exit 1
fi
printf '%s' "$login_key" | docker login "$REGISTRY" --username "${SWR_PROJECT}@${SWR_AK}" --password-stdin
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
target: metrics-processor
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# SWR rejects the OCI image index and attestation manifests that BuildKit adds by default.
provenance: false
sbom: false
push: true
publish:
if: github.event_name == 'release'
runs-on: ubuntu-latest
env:
ORG: stackmon
steps:
- uses: actions/checkout@v7
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.PROJECT }}
tags: |
type=semver,pattern=v{{version}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
env:
SWR_AK: ${{ secrets.SWR_AK }}
SWR_SK: ${{ secrets.SWR_SK }}
run: |
set -euo pipefail
if [ -z "$SWR_AK" ] || [ -z "$SWR_SK" ]; then
echo "The SWR_AK and SWR_SK repository secrets must be set" >&2
exit 1
fi
login_key="$(printf '%s' "$SWR_AK" | openssl dgst -sha256 -hmac "$SWR_SK" | awk '{print $NF}')"
if [[ ! "$login_key" =~ ^[0-9a-f]{64}$ ]]; then
echo "Cannot derive the SWR login key from the AK/SK pair" >&2
exit 1
fi
printf '%s' "$login_key" | docker login "$REGISTRY" --username "${SWR_PROJECT}@${SWR_AK}" --password-stdin
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
target: metrics-processor
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# SWR rejects the OCI image index and attestation manifests that BuildKit adds by default.
provenance: false
sbom: false
push: true