-
Notifications
You must be signed in to change notification settings - Fork 6
180 lines (163 loc) · 5.19 KB
/
controlplane.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
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
169
170
171
172
173
174
175
176
177
178
179
180
name: Release controlplane
on:
workflow_dispatch: {}
push:
branches:
- master
paths:
- "Makefile"
- "go.mod"
- "**.go"
- ".github/workflows/controlplane.yml"
- "packaging/controlplane/**"
env:
REGISTRY: europe-north1-docker.pkg.dev/nais-io/nais/images
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: tool_versions
run: echo "go=$(grep golang .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.tool_versions.outputs.go }}
- name: run tests
run: |
sudo apt-get update
sudo apt-get install --yes build-essential
make check
make test
build_debs:
name: Build debs
needs:
- test
runs-on: ubuntu-latest
container:
image: ghcr.io/nais/naisdevice-ci:v5
steps:
- uses: actions/checkout@v4
- id: tool_versions
run: echo "go=$(grep golang .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.tool_versions.outputs.go }}
- name: "Build controlplane"
run: make controlplane-debs
- name: "Auth with Google"
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GOOGLE_DEB_UPLOAD_SA_JSON }}"
- name: "Upload controlplane deb files to repository"
run: |
for component in \
"apiserver" \
"gateway-agent" \
"prometheus-agent"; do
gcloud beta artifacts apt upload controlplane --quiet --source "$component"*.deb --location europe-north1
done
build_enroller:
name: Build enroller
needs:
- test
permissions:
contents: "read"
id-token: "write"
packages: read
runs-on: ubuntu-latest
container:
image: ghcr.io/nais/naisdevice-ci:v5
steps:
- uses: actions/checkout@v4
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: "[email protected]"
token_format: "access_token"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
- name: Docker meta enroller
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/naisdevice-enroller
# Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Build and push enroller
uses: docker/build-push-action@v6
with:
context: .
file: cmd/enroller/Dockerfile
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build_auth_server:
name: Build auth-server
needs:
- test
permissions:
contents: "read"
id-token: "write"
packages: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: "[email protected]"
token_format: "access_token"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
- name: Docker meta auth-server
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/naisdevice-auth-server
# Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Build and push auth-server
uses: docker/build-push-action@v6
with:
context: .
file: cmd/auth-server/Dockerfile
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max