-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (197 loc) · 6.16 KB
/
master.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
---
name: Build & Publish
on:
push:
branches:
- master
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- master
jobs:
build-services:
runs-on: ubuntu-latest
strategy:
matrix:
service: [restaurant, order, payment, delivery, query, saga]
defaults:
run:
working-directory: ${{ matrix.service }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: corretto
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
- name: Build with Gradle
run: ./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.service }}
tags: |
type=sha
type=semver,pattern={{version}}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.service }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-shared:
runs-on: ubuntu-latest
defaults:
run:
working-directory: shared
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: corretto
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
- name: Build with Gradle
run: ./gradlew build
- name: Set TAG version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV
- name: Set SHA version
if: "!startsWith(github.ref, 'refs/tags/v')"
run: echo "VERSION=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Publish with Gradle
run: ./gradlew -Pversion="${{ env.VERSION }}" publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Download dependencies
run: npm ci
- name: Lint
run: npm run lint
# - name: Type check
# run: npm run typecheck --if-present
# - name: Run vitest
# run: npm run test -- --coverage
- name: Copy test env vars
run: cp .env.example .env
- name: Build
run: npm run build
# - name: Cypress run
# uses: cypress-io/github-action@v5
# with:
# start: npm run start:mocks
# wait-on: "http://localhost:8811"
# working-directory: ./frontend
# env:
# PORT: "8811"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/frontend
tags: |
type=sha
type=semver,pattern={{version}}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
deploy:
# if: ${{ false }} # disable for now
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [ build-services, build-shared, build-frontend ]
environment: staging
permissions:
id-token: write
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- uses: azure/setup-kubectl@v3
- uses: azure/k8s-set-context@v3
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG }}
- name: Set TAG version
run: echo "VERSION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV
- uses: Azure/k8s-deploy@v4
with:
namespace: 'thesis'
action: deploy
strategy: basic
manifests: |
k8s/main/restaurant-service-deployment.yaml
k8s/main/delivery-service-deployment.yaml
k8s/main/order-service-deployment.yaml
k8s/main/payment-service-deployment.yaml
k8s/main/query-service-deployment.yaml
k8s/main/saga-service-deployment.yaml
k8s/main/frontend-deployment.yaml
images: |
ghcr.io/bartlomiejrasztabiga/thesis/restaurant:${{ env.VERSION }}
ghcr.io/bartlomiejrasztabiga/thesis/delivery:${{ env.VERSION }}
ghcr.io/bartlomiejrasztabiga/thesis/order:${{ env.VERSION }}
ghcr.io/bartlomiejrasztabiga/thesis/payment:${{ env.VERSION }}
ghcr.io/bartlomiejrasztabiga/thesis/query:${{ env.VERSION }}
ghcr.io/bartlomiejrasztabiga/thesis/saga:${{ env.VERSION }}
ghcr.io/bartlomiejrasztabiga/thesis/frontend:${{ env.VERSION }}