-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (190 loc) · 6.73 KB
/
Copy pathpipeline.yml
File metadata and controls
208 lines (190 loc) · 6.73 KB
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
name: Pipeline
on:
push:
branches:
- main
pull_request:
jobs:
test-e2e:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-test-e2e-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: "npm"
cache-dependency-path: test/package-lock.json
- name: Install dependencies
working-directory: test
run: npm ci
- name: Install Playwright browsers
working-directory: test
run: npx playwright install chromium --with-deps
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build server image
uses: docker/build-push-action@v6
with:
context: server
load: true
tags: localhost/skeleton-app-server:test
cache-from: type=gha,scope=server
cache-to: type=gha,mode=max,scope=server
- name: Build client image
uses: docker/build-push-action@v6
with:
context: client
load: true
tags: localhost/skeleton-app-client:test
cache-from: type=gha,scope=client
cache-to: type=gha,mode=max,scope=client
- name: Build mock anthropic image
uses: docker/build-push-action@v6
with:
context: mock_anthropic_server
load: true
tags: localhost/skeleton-app-mock-anthropic:test
cache-from: type=gha,scope=mock-anthropic
cache-to: type=gha,mode=max,scope=mock-anthropic
- name: Load images into Podman
run: |
docker save localhost/skeleton-app-server:test | podman load
docker save localhost/skeleton-app-client:test | podman load
docker save localhost/skeleton-app-mock-anthropic:test | podman load
- name: Setup test environment and start pod
env:
SKIP_BUILD: "1"
run: scripts/pod_up.sh
- name: Run Playwright tests
working-directory: test
run: npx playwright test
- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results
path: test/test-results
- name: Collect pod logs
if: always()
run: |
for container in $(podman pod inspect skeleton-app-test --format '{{range .Containers}}{{.Name}} {{end}}' 2>/dev/null); do
echo "$container" | grep -q "infra" && continue
echo "=== $container ==="
podman logs "$container" 2>&1 || true
done
publish-server:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-publish-server-${{ github.ref }}
cancel-in-progress: true
needs: test-e2e
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
outputs:
hasNextVersion: ${{ steps.get_next_version.outputs.hasNextVersion }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get next version
id: get_next_version
uses: mucsi96/get-next-version@main
with:
prefix: 'server'
src: server
- name: Set up Docker Buildx
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push server image
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: docker/build-push-action@v6
with:
context: server
push: true
tags: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/skeleton-app-server:${{ steps.get_next_version.outputs.version }}
cache-from: type=gha,scope=server
cache-to: type=gha,mode=max,scope=server
- name: Create release
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_next_version.outputs.tag }}
generate_release_notes: true
publish-client:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-publish-client-${{ github.ref }}
cancel-in-progress: true
needs: test-e2e
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get next version
id: get_next_version
uses: mucsi96/get-next-version@main
with:
prefix: 'client'
src: client
- name: Set up Docker Buildx
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push client image
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: docker/build-push-action@v6
with:
context: client
push: true
tags: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/skeleton-app-client:${{ steps.get_next_version.outputs.version }}
cache-from: type=gha,scope=client
cache-to: type=gha,mode=max,scope=client
- name: Create release
if: steps.get_next_version.outputs.hasNextVersion == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_next_version.outputs.tag }}
generate_release_notes: true
deploy:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-deploy
cancel-in-progress: false
needs: [publish-server, publish-client]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6
- uses: azure/login@v3
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/use-kubelogin@v1
with:
kubelogin-version: 'v0.2.7'
- name: Deploy to Kubernetes
env:
AZURE_KEYVAULT_NAME: ${{ secrets.AZURE_KEYVAULT_NAME }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run: scripts/deploy.sh