-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (213 loc) · 7.15 KB
/
ci-cd.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
name: CI/CD
on:
push:
pull_request:
workflow_dispatch:
env:
JAVA_VERSION: 17
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Build with Gradle
uses: DanySK/[email protected]
with:
java-version: ${{ env.JAVA_VERSION }}
should-run-codecov: false
test:
needs: build
if: ${{ needs.build.result == 'success' }}
strategy:
fail-fast: false
matrix:
os:
# Commented until we find a way to run containertests on macOS and Windows
# - macos-14
# - windows-2022
- ubuntu-24.04
java-version: [17, 21]
java-distribution:
- adopt
- corretto
runs-on: ${{ matrix.os }}
concurrency:
group: build-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.java-version }}-${{ matrix.java-distribution }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/[email protected]
- uses: DanySK/[email protected]
with:
java-version: ${{ matrix.java-version }}
java-distribution: ${{ matrix.java-distribution }}
should-run-codecov: false
release:
needs:
- build
- test
if: >-
github.event_name != 'pull_request'
&& github.ref == 'refs/heads/main'
&& contains(needs.*.result, 'success')
&& !contains(needs.*.result, 'failure')
&& !github.event.repository.fork
concurrency:
group: release-${{ github.event.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Produce coverage report
uses: DanySK/[email protected]
with:
should-run-codecov: false
check-command: "./gradlew koverXmlReport --parallel || ./gradlew koverXmlReport --parallel"
- name: Push coverage report
uses: codecov/[email protected]
with:
files: ./build/reports/kover/report.xml
verbose: true
slug: zucchero-sintattico/piper-kt
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install dependencies
run: npm install
- name: Avoid git hooks during release
run: rm -rf .git/hooks
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: Check version for release
id: check-version
shell: bash
run: |
GIT_VERSION=$(git describe --tags --exact-match HEAD || echo '')
if [ -n "$GIT_VERSION" ]; then
echo "version=$(echo $GIT_VERSION | sed 's/^v//')" >> "$GITHUB_OUTPUT"
fi
pages-deploy:
needs: release
if: >-
needs.release.result == 'success'
&& needs.release.outputs.version != ''
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
env:
TMP_SITE: tmp-site
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- run: echo "Deploying version ${{ needs.release.outputs.version }} to GitHub Page"
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod for Hugo
- uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Deploy to NPM
run: ./gradlew -Pversion=${{ needs.release.outputs.version }} :events:publishJsPackageToNpmjsRegistry --parallel
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Create artifacts directory
run: |
mkdir -p ${{ env.TMP_SITE }}
cp ./resources/index-github-pages.html ${{ env.TMP_SITE }}/index.html
- name: Build documentation
run: |
./gradlew -PforceVersion=${{ needs.release.outputs.version }} dokkaHtmlMultiModule --parallel
cp -r ./build/dokka/htmlMultiModule ${{ env.TMP_SITE }}/docs
- name: Build Open API documentation
run: |
./gradlew buildOpenApiSite --parallel
cp -r ./build/openapi-site ${{ env.TMP_SITE }}/openapi
cp -r ./resources/bdd-report ${{ env.TMP_SITE }}/bdd
cp -r ./resources/asyncapi-site ${{ env.TMP_SITE }}/asyncapi
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Build Site with Vitepress
working-directory: ./resources/report
run: |
npm ci
npm run docs:build -- --base /piper-kt/report/ --outDir ../../${{ env.TMP_SITE }}/report
- name: Upload artifact
uses: actions/[email protected]
with:
path: ${{ env.TMP_SITE }}
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]
image-delivery:
name: ${{ matrix.service }} image delivery to Docker Hub
needs: release
if: >-
needs.release.result == 'success'
&& needs.release.outputs.version != ''
runs-on: ubuntu-latest
strategy:
matrix:
service:
- "friendships-service"
- "frontend-service"
- "multimedia-service"
- "notifications-service"
- "servers-service"
- "users-service"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Produce Dockerfile for ${{ matrix.service }}
uses: DanySK/[email protected]
with:
should-run-codecov: false
build-command: "./gradlew :${{ matrix.service }}:buildLayers && ./gradlew :${{ matrix.service }}:dockerfile"
check-command: ":"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push ${{ matrix.service }} image
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.service }}/build/docker/main # path of Dockerfile generated by micronaut
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
zuccherosintattico/piperkt-${{ matrix.service }}:${{ needs.release.outputs.version }}
zuccherosintattico/piperkt-${{ matrix.service }}:latest