-
Notifications
You must be signed in to change notification settings - Fork 3
190 lines (163 loc) · 5.61 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
name: CI
on:
push:
branches: [ main ]
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request: {}
env:
GO_VERSION: "1.23"
BUILD_PLATFORMS: linux/amd64,linux/arm64
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go tools
uses: actions/cache@v4
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@v4
with:
# Don't use merge ref to ensure sha- image tag is accurate
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- 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 }}
platforms: ${{ env.BUILD_PLATFORMS }}
- 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 }}
platforms: ${{ env.BUILD_PLATFORMS }}
helm:
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.15.4
- 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 "artifact=hephaestus-${semantic_version}.tgz" >> $GITHUB_OUTPUT
- 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
env:
MAVEN_DOCKER_IMAGE: maven:3-eclipse-temurin-17
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Generate SDKS
run: |
export BRANCH_NAME=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | sed -r 's|/+|-|g')
make sdks
- name: Generate Java JAR
run: |
docker run -q --rm \
--workdir /wd \
--volume $HOME/.m2:/root/.m2 \
--volume $(pwd)/sdks/java:/wd \
$MAVEN_DOCKER_IMAGE mvn --settings settings.xml package
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: hephaestus-client-java.jar
path: sdks/java/target/*.jar
if-no-files-found: error
- name: Publish JAR to GitHub
run: |
docker run --rm \
--workdir /wd \
--volume $HOME/.m2:/root/.m2 \
--volume $(pwd)/sdks/java:/wd \
--env ARTIFACTORY_USERNAME=${{ secrets.ARTIFACTORY_USERNAME }} \
--env ARTIFACTORY_PASSWORD=${{ secrets.ARTIFACTORY_PASSWORD }} \
--env GITHUB_USERNAME=${{ github.actor }} \
--env GITHUB_PASSWORD=${{ secrets.GITHUB_TOKEN }} \
$MAVEN_DOCKER_IMAGE mvn --settings settings.xml --activate-profiles github -DskipTests deploy
- name: Publish Jar to Artifactory
uses: nick-fields/retry@v3
with:
retry_on: error
max_attempts: 10
timeout_minutes: 1
retry_wait_seconds: 5
command: |
docker run --rm \
--workdir /wd \
--volume $HOME/.m2:/root/.m2 \
--volume $(pwd)/sdks/java:/wd \
--env ARTIFACTORY_USERNAME=${{ secrets.ARTIFACTORY_USERNAME }} \
--env ARTIFACTORY_PASSWORD=${{ secrets.ARTIFACTORY_PASSWORD }} \
--env GITHUB_USERNAME=${{ github.actor }} \
--env GITHUB_PASSWORD=${{ secrets.GITHUB_TOKEN }} \
$MAVEN_DOCKER_IMAGE mvn --settings settings.xml --activate-profiles artifactory -DskipTests deploy