generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 2
169 lines (142 loc) · 4.87 KB
/
build.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
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
158
159
160
161
162
163
164
165
166
167
168
name: Build artifacts
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency: build-${{ github.ref }}
env:
REGISTRY: ghcr.io
defaults:
run:
shell: bash
jobs:
test:
name: Run tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Check that license header boilerplate is correct
uses: sap/cs-actions/check-go-license-boilerplate@main
with:
boilerplate-path: hack/boilerplate.go.txt
- name: Check that license headers are correct
uses: sap/cs-actions/check-go-license-headers@main
with:
boilerplate-path: hack/boilerplate.go.txt
- name: Check that generated artifacts are up-to-date
run: |
make generate
echo "Running 'git status' ..."
if [ -z "$(git status --porcelain)" ]; then
echo "Generated artifacts are up-to-date."
else
>&2 echo "Generated artifacts are not up-to-date; probably 'make generate' was not run before committing."
exit 1
fi
- name: Run tests
run: |
go test -count 1 ./...
build-docker_controller:
name: Build Docker image (controller)
runs-on: ubuntu-22.04
needs: test
permissions:
contents: read
outputs:
image-archive: image_controller.tar
image-repository: ${{ steps.prepare-repository-name.outputs.repository }}
image-tag: ${{ steps.extract-metadata.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare repository name
id: prepare-repository-name
run: |
repository=$REGISTRY/${{ github.repository }}/controller
echo "repository=${repository,,}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: extract-metadata
uses: docker/metadata-action@v5
with:
images: ${{ steps.prepare-repository-name.outputs.repository }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: build/controller/Dockerfile
cache-from: |
type=gha,scope=sha-${{ github.sha }}/controller
type=gha,scope=${{ github.ref_name }}/controller
type=gha,scope=${{ github.base_ref || 'main' }}/controller
type=gha,scope=main/controller
cache-to: |
type=gha,scope=sha-${{ github.sha }}/controller,mode=max
type=gha,scope=${{ github.ref_name }}/controller,mode=max
outputs: |
type=oci,dest=${{ runner.temp }}/image_controller.tar
tags: ${{ steps.extract-metadata.outputs.tags }}
labels: ${{ steps.extract-metadata.outputs.labels }}
- name: Upload Docker image archive
uses: actions/upload-artifact@v4
with:
name: image_controller.tar
path: ${{ runner.temp }}/image_controller.tar
build-docker_webhook:
name: Build Docker image (webhook)
runs-on: ubuntu-22.04
needs: test
permissions:
contents: read
outputs:
image-archive: image_webhook.tar
image-repository: ${{ steps.prepare-repository-name.outputs.repository }}
image-tag: ${{ steps.extract-metadata.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare repository name
id: prepare-repository-name
run: |
repository=$REGISTRY/${{ github.repository }}/webhook
echo "repository=${repository,,}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: extract-metadata
uses: docker/metadata-action@v5
with:
images: ${{ steps.prepare-repository-name.outputs.repository }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: build/webhook/Dockerfile
cache-from: |
type=gha,scope=sha-${{ github.sha }}/webhook
type=gha,scope=${{ github.ref_name }}/webhook
type=gha,scope=${{ github.base_ref || 'main' }}/webhook
type=gha,scope=main/webhook
cache-to: |
type=gha,scope=sha-${{ github.sha }}/webhook,mode=max
type=gha,scope=${{ github.ref_name }}/webhook,mode=max
outputs: |
type=oci,dest=${{ runner.temp }}/image_webhook.tar
tags: ${{ steps.extract-metadata.outputs.tags }}
labels: ${{ steps.extract-metadata.outputs.labels }}
- name: Upload Docker image archive
uses: actions/upload-artifact@v4
with:
name: image_webhook.tar
path: ${{ runner.temp }}/image_webhook.tar