-
Notifications
You must be signed in to change notification settings - Fork 5
229 lines (193 loc) · 6.54 KB
/
main.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: CI
on:
push:
branches: [ main ]
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
branches: [ main ]
env:
GO_VERSION: 1.18
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache Go tools
uses: actions/cache@v2
with:
path: ~/go/bin
key: ${{ runner.os }}-go-tools-${{ hashFiles('tools/go.sum') }}
restore-keys: |
${{ runner.os }}-go-tools-
- name: Sanity check
run: make check
- name: Build
run: make build
- name: Lint
run: make lint
- name: Unit test
run: make test
docker:
runs-on: ubuntu-latest
needs: build
outputs:
version: ${{ steps.docker_push.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- id: docker_push
name: Push Docker image to GHCR
uses: ./.github/actions/push-docker-image
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to Quay
uses: ./.github/actions/push-docker-image
with:
registry: quay.io
repository: domino/hephaestus
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
# TODO: refactor this job and vendor-buildkit / vendor-vector to remove duplication
vendor-buildkit-rootless:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- id: image_tag
name: Extract image details from Helm values
uses: mikefarah/yq@v4.25.1
with:
cmd: yq '.buildkit.image.tag' deployments/helm/hephaestus/values.yaml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to container registry
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push rootless Buildkit image to Quay
uses: docker/build-push-action@v3
with:
context: build/buildkit
push: true
build-args: BUILDKIT_TAG=${{ steps.image_tag.outputs.result }}
tags: quay.io/domino/buildkit:${{ steps.image_tag.outputs.result }}
cache-from: type=gha, scope=${{ github.job }}
cache-to: type=gha, scope=${{ github.job }}
vendor-buildkit:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Push root Buildkit image to Quay
uses: ./.github/actions/vendor-docker-image
with:
query: ".buildkit.image"
modifier: "sed 's/-rootless//'"
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
vendor-vector:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Push Vector image to Quay
uses: ./.github/actions/vendor-docker-image
with:
query: ".logProcessor.image"
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
helm:
runs-on: ubuntu-latest
needs:
- docker
- vendor-buildkit
- vendor-vector
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1
- id: helm_pkg
name: Package Helm chart
shell: bash
run: |
app_version="${{ needs.docker.outputs.version }}"
if [[ $app_version =~ ^(pr-[[:digit:]]+|main)$ ]]; then
semantic_version="0.0.0-$app_version"
else
semantic_version=$app_version
fi
helm package deployments/helm/hephaestus --app-version "$app_version" --version "$semantic_version"
echo ::set-output name=artifact::"hephaestus-${semantic_version}.tgz"
- name: Push Helm chart to GHCR
uses: ./.github/actions/push-helm-chart
with:
registry: ghcr.io
namespace: "${{ github.repository_owner }}/helm"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
artifact: ${{ steps.helm_pkg.outputs.artifact }}
- name: Push Helm chart to GCR
uses: ./.github/actions/push-helm-chart
with:
registry: gcr.io
namespace: ${{ secrets.GCR_NAMESPACE }}
username: ${{ secrets.GCR_USERNAME }}
password: ${{ secrets.GCR_PASSWORD }}
password_base64_encoded: "true"
artifact: ${{ steps.helm_pkg.outputs.artifact }}
sdks:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install KinD
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.11.1"
skipClusterCreation: true
- name: Generate SDKS
run: make sdks
- name: Generate Java JAR
run: docker run --rm -v $HOME/.m2:/root/.m2 -v $(pwd)/sdks/java:/wd --workdir /wd maven:3-openjdk-8 mvn -s settings.xml package
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: hephaestus-client-java.jar
path: sdks/java/target/*.jar
if-no-files-found: error
- name: Publish Java JAR
run: docker run --rm -v $HOME/.m2:/root/.m2 -v $(pwd)/sdks/java:/wd -e JAVA_SDK_MAVEN_USERNAME=${{ github.actor }} -e JAVA_SDK_MAVEN_PASSWORD=${{ secrets.GITHUB_TOKEN }} --workdir /wd maven:3-openjdk-8 mvn -s settings.xml deploy -DskipTests -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/dominodatalab/hephaestus
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}