Skip to content

Commit 14bef7a

Browse files
committed
Use second job to add translations
1 parent ff9fe36 commit 14bef7a

File tree

4 files changed

+140
-204
lines changed

4 files changed

+140
-204
lines changed

.github/workflows/builder.yml

Lines changed: 84 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
channel: ${{ steps.version.outputs.channel }}
3636
publish: ${{ steps.version.outputs.publish }}
3737
architectures: ${{ env.ARCHITECTURES }}
38-
translation_download_process: ${{ steps.translations.outputs.translation_download_process }}
3938
base_image_version: ${{ env.BASE_IMAGE_VERSION }}
4039
steps:
4140
- name: Checkout the repository
@@ -48,26 +47,6 @@ jobs:
4847
with:
4948
python-version-file: ".python-version"
5049

51-
- name: Fail if translations files are checked in
52-
run: |
53-
if [ -n "$(find homeassistant/components/*/translations -type f)" ]; then
54-
echo "Translations files are checked in, please remove the following files:"
55-
find homeassistant/components/*/translations -type f
56-
exit 1
57-
fi
58-
59-
- name: Start translation download
60-
id: translations
61-
shell: bash
62-
env:
63-
LOKALISE_TOKEN: ${{ secrets.LOKALISE_TOKEN }} # zizmor: ignore[secrets-outside-env]
64-
run: |
65-
pip install -r script/translations/requirements.txt
66-
PROCESS_OUTPUT=$(python3 -m script.translations download --async-start)
67-
echo "$PROCESS_OUTPUT"
68-
TRANSLATION_DOWNLOAD_PROCESS=$(echo "$PROCESS_OUTPUT" | sed -n 's/.*Process ID: //p')
69-
echo "translation_download_process=$TRANSLATION_DOWNLOAD_PROCESS" >> "$GITHUB_OUTPUT"
70-
7150
- name: Get information
7251
id: info
7352
uses: home-assistant/actions/helpers/info@master # zizmor: ignore[unpinned-uses]
@@ -83,8 +62,16 @@ jobs:
8362
with:
8463
ignore-dev: true
8564

65+
- name: Fail if translations files are checked in
66+
run: |
67+
if [ -n "$(find homeassistant/components/*/translations -type f)" ]; then
68+
echo "Translations files are checked in, please remove the following files:"
69+
find homeassistant/components/*/translations -type f
70+
exit 1
71+
fi
72+
8673
build_base:
87-
name: Build ${{ matrix.arch }} base core image
74+
name: Build ${{ matrix.arch }} base core image without translations
8875
if: github.repository_owner == 'home-assistant'
8976
needs: init
9077
runs-on: ${{ matrix.os }}
@@ -93,14 +80,15 @@ jobs:
9380
packages: write # To push to GHCR
9481
id-token: write # For cosign signing
9582
strategy:
96-
fail-fast: false
97-
matrix:
98-
arch: ${{ fromJson(needs.init.outputs.architectures) }}
99-
include:
100-
- arch: amd64
101-
os: ubuntu-24.04
102-
- arch: aarch64
103-
os: ubuntu-24.04-arm
83+
<<: &base_build_strategy
84+
fail-fast: false
85+
matrix:
86+
arch: ${{ fromJson(needs.init.outputs.architectures) }}
87+
include:
88+
- arch: amd64
89+
os: ubuntu-24.04
90+
- arch: aarch64
91+
os: ubuntu-24.04-arm
10492
steps:
10593
- name: Checkout the repository
10694
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -130,6 +118,7 @@ jobs:
130118
name: package
131119

132120
- name: Set up Python
121+
if: needs.init.outputs.channel == 'dev'
133122
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
134123
with:
135124
python-version-file: ".python-version"
@@ -182,8 +171,8 @@ jobs:
182171
run: |
183172
echo "${GITHUB_SHA};${GITHUB_REF};${GITHUB_EVENT_NAME};${GITHUB_ACTOR}" > rootfs/OFFICIAL_IMAGE
184173
185-
- name: Build base image (deps stage only)
186-
uses: edenhaus/builder/actions/build-image@b3ea9d4b1d98f979d671aa8442ad8373e38aea11
174+
- name: Build base image without translations
175+
uses: home-assistant/builder/actions/build-image@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
187176
with:
188177
arch: ${{ matrix.arch }}
189178
build-args: |
@@ -192,30 +181,79 @@ jobs:
192181
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
193182
cosign-base-identity: "https://github.com/home-assistant/docker/.*"
194183
cosign-base-verify: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant-base:${{ needs.init.outputs.base_image_version }}
195-
image: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant
196-
image-tags: base-intermediate
197-
push: false
198-
load: true
184+
image: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant-no-translations
185+
image-tags: ${{ needs.init.outputs.version }}
186+
push: true
199187
version: ${{ needs.init.outputs.version }}
200188

201-
- name: Download translations
202-
shell: bash
189+
download_translations:
190+
name: Download translations
191+
needs: init
192+
if: github.repository_owner == 'home-assistant'
193+
runs-on: ubuntu-latest
194+
permissions:
195+
contents: read # To check out the repository
196+
steps:
197+
- name: Checkout the repository
198+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
199+
with:
200+
persist-credentials: false
201+
202+
- name: Set up Python
203+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
204+
with:
205+
python-version-file: ".python-version"
206+
207+
- name: Download Translations
208+
run: python3 -m script.translations download
203209
env:
204210
LOKALISE_TOKEN: ${{ secrets.LOKALISE_TOKEN }} # zizmor: ignore[secrets-outside-env]
205-
TRANSLATION_PROCESS_ID: ${{ needs.init.outputs.translation_download_process }}
206-
run: |
207-
pip install -r script/translations/requirements.txt
208-
python3 -u -m script.translations download --process-id "$TRANSLATION_PROCESS_ID" --output-dir build/translations-output
211+
212+
- name: Archive translations
213+
shell: bash
214+
run: find ./homeassistant/components/*/translations -name "*.json" | tar zcvf translations.tar.gz -T -
215+
216+
- name: Upload translations
217+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
218+
with:
219+
name: translations
220+
path: translations.tar.gz
221+
if-no-files-found: error
222+
223+
build_translations:
224+
name: Build ${{ matrix.arch }} core image with translations
225+
if: github.repository_owner == 'home-assistant'
226+
needs: ["init", "build_base", "download_translations"]
227+
runs-on: ${{ matrix.os }}
228+
permissions:
229+
contents: read # To check out the repository
230+
packages: write # To push to GHCR
231+
id-token: write # For cosign signing
232+
strategy:
233+
<<: *base_build_strategy
234+
steps:
235+
- name: Checkout the repository
236+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
237+
with:
238+
persist-credentials: false
239+
240+
- name: Download translations artifact
241+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
242+
with:
243+
name: translations
244+
path: build/translations-output
209245

210246
- name: Build translations image
211247
uses: home-assistant/builder/actions/build-image@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
212248
with:
213249
arch: ${{ matrix.arch }}
214250
build-args: |
215-
BUILD_FROM=ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:base-intermediate
251+
BUILD_FROM=ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant-no-translations:${{ needs.init.outputs.version }}
216252
cache-gha: false
217253
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
218254
context: build/translations-output
255+
cosign-base-identity: "https://github.com/home-assistant/core/.*"
256+
cosign-base-verify: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant-no-translations:${{ needs.init.outputs.version }}
219257
file: Dockerfile.translations
220258
image: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant
221259
image-tags: ${{ needs.init.outputs.version }}
@@ -225,7 +263,7 @@ jobs:
225263
build_machine:
226264
name: Build ${{ matrix.machine }} machine core image
227265
if: github.repository_owner == 'home-assistant'
228-
needs: ["init", "build_base"]
266+
needs: ["init", "build_translations"]
229267
runs-on: ${{ matrix.runs-on }}
230268
permissions:
231269
contents: read # To check out the repository
@@ -341,7 +379,7 @@ jobs:
341379
name: Publish meta container for ${{ matrix.registry }}
342380
environment: ${{ needs.init.outputs.channel }}
343381
if: github.repository_owner == 'home-assistant'
344-
needs: ["init", "build_base"]
382+
needs: ["init", "build_translations"]
345383
runs-on: ubuntu-latest
346384
permissions:
347385
contents: read # To check out the repository
@@ -478,7 +516,7 @@ jobs:
478516
build_python:
479517
name: Build PyPi package
480518
environment: ${{ needs.init.outputs.channel }}
481-
needs: ["init", "build_base"]
519+
needs: ["init", "download_translations"]
482520
runs-on: ubuntu-latest
483521
permissions:
484522
contents: read # To check out the repository

0 commit comments

Comments
 (0)