-
Notifications
You must be signed in to change notification settings - Fork 25
229 lines (212 loc) · 7.64 KB
/
release.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: Build and Publish
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: "The tag to build the image with. Format *.*.*((beta|rc)*)?"
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docker-metadata:
name: Generate docker metadata
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'require-build')) || (github.event_name != 'pull_request' && !cancelled()) }}
outputs:
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
annotations: ${{steps.meta.outputs.annotations}}
platforms: |
linux/amd64
${{(startsWith(github.ref, 'refs/tags/') && 'linux/arm64') || ''}}
permissions:
contents: read
steps:
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
github-token: ${{ github.token }}
images: "{0}/{1}"
tags: |
type=raw,value=branch-{{branch}},enable=${{ !startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/pull/') }}
type=sha,prefix=sha-,format=long,suffix=-dev,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
type=sha,prefix=sha-,format=long,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=pr
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{version}}
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{major}}.{{minor}}
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{major}}
build-backend:
name: Build and Push Backend Image
runs-on: ubuntu-latest
needs: docker-metadata
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_USERNAME }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push backend
uses: docker/build-push-action@v6
with:
context: backend
platforms: ${{needs.docker-metadata.outputs.platforms}}
push: true
tags: ${{format(needs.docker-metadata.outputs.tags, secrets.RELEASE_DOCKERHUB_USERNAME, 'backend')}}
labels: ${{needs.docker-metadata.outputs.labels}}
annotations: ${{needs.docker-metadata.outputs.annotations}}
cache-from: type=gha
cache-to: type=gha,mode=max
build-frontend:
name: Build and Push Frontend Image
runs-on: ubuntu-latest
needs: docker-metadata
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_USERNAME }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push frontend
uses: docker/build-push-action@v6
with:
context: .
file: ./frontend/Dockerfile
platforms: ${{needs.docker-metadata.outputs.platforms}}
push: true
tags: ${{format(needs.docker-metadata.outputs.tags, secrets.RELEASE_DOCKERHUB_USERNAME, 'frontend')}}
labels: ${{needs.docker-metadata.outputs.labels}}
annotations: ${{needs.docker-metadata.outputs.annotations}}
cache-from: type=gha
cache-to: type=gha,mode=max
e2e-test:
name: E2E Test
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: e2e
needs:
- build-backend
- build-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
cache-dependency-path: e2e/package-lock.json
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run tests
run: ./start-test.sh
env:
E2E_DOCKER_TAG: sha-${{ github.sha }}-dev
E2E_LLM_PROVIDER: ${{vars.E2E_LLM_PROVIDER}}
E2E_LLM_MODEL: ${{vars.E2E_LLM_MODEL || ''}}
E2E_LLM_CREDENTIALS: ${{secrets.E2E_LLM_CREDENTIALS}}
E2E_EMBEDDING_PROVIDER: ${{vars.E2E_EMBEDDING_PROVIDER || 'openai'}}
E2E_EMBEDDING_MODEL: ${{vars.E2E_EMBEDDING_MODEL || ''}}
E2E_EMBEDDING_CREDENTIALS: ${{secrets.E2E_EMBEDDING_CREDENTIALS}}
E2E_RERANKER_PROVIDER: ${{vars.E2E_RERANKER_PROVIDER || 'jinaai'}}
E2E_RERANKER_MODEL: ${{vars.E2E_RERANKER_MODEL || ''}}
E2E_RERANKER_CREDENTIALS: ${{secrets.E2E_RERANKER_CREDENTIALS}}
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: e2e-report
path: e2e/playwright-report/
retention-days: 30
e2e-test-deploy:
name: "Deploy E2E Test Results"
runs-on: ubuntu-latest
needs: e2e-test
if: "!(contains(needs.*.result, 'skipped')) && !cancelled()"
defaults:
run:
working-directory: e2e
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/download-artifact@v4
with:
name: e2e-report
path: e2e/playwright-report/
- name: Deploy Test Results to Vercel
id: deploy-test-result
run: |
deploy_message=$(./deploy-test-result.sh)
echo "deploy-message=${deploy_message}" >> $GITHUB_OUTPUT
if: "!cancelled()"
env:
VERCEL_TOKEN: ${{secrets.E2E_VERCEL_TOKEN}}
VERCEL_ORG_ID: ${{secrets.E2E_VERCEL_ORG_ID}}
VERCEL_PROJECT_ID: ${{secrets.E2E_VERCEL_PROJECT_ID}}
VERCEL_CLI_ARGS: ${{(github.ref == 'refs/heads/main' && '--prod') || ''}}
- name: Find PR Comment
uses: peter-evans/find-comment@v3
if: github.event.pull_request.number
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: E2E Result Deployment
- name: Upsert Comment on PR
uses: peter-evans/create-or-update-comment@v4
if: github.event.pull_request.number
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### E2E Result Deployment
${{steps.deploy-test-result.outputs.deploy-message}}
edit-mode: replace