Skip to content

Commit fa1d0a6

Browse files
authored
feat: optimize release (#2417)
1 parent 9819b6c commit fa1d0a6

File tree

3 files changed

+56
-19
lines changed

3 files changed

+56
-19
lines changed

.bin/scripts/release-app.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ readonly next_version="${1}"
1313
readonly COMMIT_HASH="${2}"
1414
readonly mode=${3:-$defaultMode}
1515

16-
"$ROOT_DIR/.bin/scripts/build-images.sh" $next_version $mode $COMMIT_HASH production recette pentest
16+
"$ROOT_DIR/.bin/scripts/build-images.sh" $next_version $mode $COMMIT_HASH production

.github/workflows/release.yml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,48 @@ jobs:
6363
id: get-version
6464
run: echo "VERSION=$(git describe --tags --abbrev=0 | cut -c2-)" >> "$GITHUB_OUTPUT"
6565

66+
build-ui-envs:
67+
needs: ["release"]
68+
if: needs.release.outputs.VERSION != needs.release.outputs.PREV_VERSION
69+
runs-on: ubuntu-latest
70+
strategy:
71+
matrix:
72+
env: [recette, pentest]
73+
steps:
74+
- name: Checkout project
75+
uses: actions/checkout@v5
76+
with:
77+
fetch-depth: 0
78+
79+
- uses: actions/setup-node@v6
80+
with:
81+
node-version: 24
82+
cache: "yarn"
83+
84+
- name: Install dependencies
85+
run: yarn install --immutable
86+
87+
- name: Set up Docker Buildx
88+
uses: docker/setup-buildx-action@v3
89+
with:
90+
platforms: linux/amd64
91+
install: true
92+
93+
- name: Login to GitHub Container Registry
94+
uses: docker/login-action@v3
95+
with:
96+
registry: ghcr.io
97+
username: ${{ github.actor }}
98+
password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Expose GitHub Runtime
101+
uses: crazy-max/ghaction-github-runtime@v2
102+
103+
- name: Build UI ${{ matrix.env }}
104+
run: .bin/scripts/build-images.sh ${{ needs.release.outputs.VERSION }} push $(git rev-parse HEAD) ${{ matrix.env }}
105+
env:
106+
CI: true
107+
66108
docker-scout-server:
67109
if: needs.release.outputs.VERSION != needs.release.outputs.PREV_VERSION
68110
needs: ["release"]
@@ -120,7 +162,7 @@ jobs:
120162
deploy-recette:
121163
concurrency:
122164
group: "deploy-${{ github.workflow }}-${{ github.ref }}"
123-
needs: ["release"]
165+
needs: ["release", "build-ui-envs"]
124166
name: Deploy ${{ needs.release.outputs.VERSION }} on recette
125167
uses: "./.github/workflows/_deploy.yml"
126168
with:
@@ -135,7 +177,7 @@ jobs:
135177
deploy-pentest:
136178
concurrency:
137179
group: "deploy-pentest-${{ github.workflow }}-${{ github.ref }}"
138-
needs: ["release"]
180+
needs: ["release", "build-ui-envs"]
139181
name: Deploy ${{ needs.release.outputs.VERSION }} on pentest
140182
uses: "./.github/workflows/_deploy.yml"
141183
with:
@@ -157,27 +199,23 @@ jobs:
157199
fetch-depth: 0
158200
persist-credentials: true
159201

160-
- uses: actions/setup-node@v6
161-
with:
162-
node-version: 24
163-
cache: "yarn"
164-
165-
- name: Install dependencies
166-
run: yarn install --immutable
167-
168-
- name: Build sourcemaps
169-
run: yarn build
170-
env:
171-
NEXT_PUBLIC_ENV: production
172-
NEXT_PUBLIC_VERSION: ${{ needs.release.outputs.VERSION }}
173-
174202
- name: Login to GitHub Container Registry
175203
uses: docker/login-action@v3
176204
with:
177205
registry: ghcr.io
178206
username: ${{ github.actor }}
179207
password: ${{ secrets.GITHUB_TOKEN }}
180208

209+
- name: Pull UI production image
210+
run: docker pull ghcr.io/mission-apprentissage/mna_lba_ui:${{ needs.release.outputs.VERSION }}-production
211+
212+
- name: Extract sourcemaps from Docker image
213+
run: |
214+
docker create --name temp-ui ghcr.io/mission-apprentissage/mna_lba_ui:${{ needs.release.outputs.VERSION }}-production
215+
mkdir -p ui/.next
216+
docker cp temp-ui:/app/ui/.next/static ./ui/.next/static
217+
docker rm temp-ui
218+
181219
- name: Create vault pwd file
182220
run: echo ${{ secrets.VAULT_PWD }} > .infra/.vault_pwd.txt
183221

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ ENV __RRWEB_EXCLUDE_IFRAME__=true
8686
ENV __RRWEB_EXCLUDE_SHADOW_DOM__=true
8787
ENV __SENTRY_EXCLUDE_REPLAY_WORKER__=true
8888

89-
RUN yarn --cwd ui build
90-
# RUN --mount=type=cache,target=/app/ui/.next/cache yarn --cwd ui build
89+
RUN --mount=type=cache,target=/app/ui/.next/cache yarn --cwd ui build
9190

9291
# Production image, copy all the files and run next
9392
FROM node:24-slim AS ui

0 commit comments

Comments
 (0)