Skip to content

Commit c353d9f

Browse files
authored
Use yaml anchors for workflow (#316)
1 parent 1974df4 commit c353d9f

File tree

1 file changed

+23
-65
lines changed

1 file changed

+23
-65
lines changed

.github/workflows/builder.yml

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
init:
1919
name: Initialize build
20-
runs-on: ubuntu-24.04
20+
runs-on: &runs-on-ubuntu ubuntu-24.04
2121
outputs:
2222
architectures_alpine: ${{ steps.info_alpine.outputs.architectures }}
2323
architectures_debian: ${{ steps.info_debian.outputs.architectures }}
@@ -63,8 +63,8 @@ jobs:
6363
build_alpine:
6464
name: Build ${{ matrix.arch }} alpine ${{ matrix.version }} base image
6565
needs: init
66-
runs-on: ubuntu-24.04
67-
permissions:
66+
runs-on: *runs-on-ubuntu
67+
permissions: &permissions
6868
contents: read
6969
id-token: write
7070
packages: write
@@ -73,10 +73,12 @@ jobs:
7373
arch: ${{ fromJson(needs.init.outputs.architectures_alpine) }}
7474
version: ["3.19", "3.20", "3.21", "3.22"]
7575
steps:
76-
- name: Checkout the repository
76+
- &checkout
77+
name: Checkout the repository
7778
uses: actions/[email protected]
7879

79-
- name: Login to GitHub Container Registry
80+
- &login-container-registry
81+
name: Login to GitHub Container Registry
8082
if: github.event_name == 'release'
8183
uses: docker/login-action@v3
8284
with:
@@ -107,26 +109,15 @@ jobs:
107109
build_debian:
108110
name: Build ${{ matrix.arch }} debian ${{ matrix.version }} base image
109111
needs: init
110-
runs-on: ubuntu-24.04
111-
permissions:
112-
contents: read
113-
id-token: write
114-
packages: write
112+
runs-on: *runs-on-ubuntu
113+
permissions: *permissions
115114
strategy:
116115
matrix:
117116
arch: ${{ fromJson(needs.init.outputs.architectures_debian) }}
118117
version: ["bookworm", "trixie"]
119118
steps:
120-
- name: Checkout the repository
121-
uses: actions/[email protected]
122-
123-
- name: Login to GitHub Container Registry
124-
if: github.event_name == 'release'
125-
uses: docker/login-action@v3
126-
with:
127-
registry: ghcr.io
128-
username: ${{ github.repository_owner }}
129-
password: ${{ secrets.GITHUB_TOKEN }}
119+
- *checkout
120+
- *login-container-registry
130121

131122
- name: Set build arguments
132123
shell: bash
@@ -152,26 +143,15 @@ jobs:
152143
build_ubuntu:
153144
name: Build ${{ matrix.arch }} ubuntu ${{ matrix.version }} base image
154145
needs: init
155-
runs-on: ubuntu-24.04
156-
permissions:
157-
contents: read
158-
id-token: write
159-
packages: write
146+
runs-on: *runs-on-ubuntu
147+
permissions: *permissions
160148
strategy:
161149
matrix:
162150
arch: ${{ fromJson(needs.init.outputs.architectures_ubuntu) }}
163151
version: ["16.04", "18.04", "20.04", "22.04", "24.04"]
164152
steps:
165-
- name: Checkout the repository
166-
uses: actions/[email protected]
167-
168-
- name: Login to GitHub Container Registry
169-
if: github.event_name == 'release'
170-
uses: docker/login-action@v3
171-
with:
172-
registry: ghcr.io
173-
username: ${{ github.repository_owner }}
174-
password: ${{ secrets.GITHUB_TOKEN }}
153+
- *checkout
154+
- *login-container-registry
175155

176156
- name: Set build arguments
177157
shell: bash
@@ -196,26 +176,15 @@ jobs:
196176
build_raspbian:
197177
name: Build ${{ matrix.arch }} raspbian ${{ matrix.version }} base image
198178
needs: init
199-
runs-on: ubuntu-24.04
200-
permissions:
201-
contents: read
202-
id-token: write
203-
packages: write
179+
runs-on: *runs-on-ubuntu
180+
permissions: *permissions
204181
strategy:
205182
matrix:
206183
arch: ${{ fromJson(needs.init.outputs.architectures_raspbian) }}
207184
version: ["bookworm", "trixie"]
208185
steps:
209-
- name: Checkout the repository
210-
uses: actions/[email protected]
211-
212-
- name: Login to GitHub Container Registry
213-
if: github.event_name == 'release'
214-
uses: docker/login-action@v3
215-
with:
216-
registry: ghcr.io
217-
username: ${{ github.repository_owner }}
218-
password: ${{ secrets.GITHUB_TOKEN }}
186+
- *checkout
187+
- *login-container-registry
219188

220189
- name: Set build arguments
221190
shell: bash
@@ -241,28 +210,17 @@ jobs:
241210
build_python:
242211
name: Build ${{ matrix.arch }} alpine ${{ matrix.version }} - python ${{ matrix.python }} base image
243212
needs: [init, build_alpine]
244-
runs-on: ubuntu-24.04
245-
permissions:
246-
contents: read
247-
id-token: write
248-
packages: write
213+
runs-on: *runs-on-ubuntu
214+
permissions: *permissions
249215
strategy:
250216
fail-fast: false
251217
matrix:
252218
arch: ${{ fromJson(needs.init.outputs.architectures_alpine) }}
253219
version: ["3.20", "3.21", "3.22"]
254220
python: ["3.11", "3.12", "3.13"]
255221
steps:
256-
- name: Checkout the repository
257-
uses: actions/[email protected]
258-
259-
- name: Login to GitHub Container Registry
260-
if: github.event_name == 'release'
261-
uses: docker/login-action@v3
262-
with:
263-
registry: ghcr.io
264-
username: ${{ github.repository_owner }}
265-
password: ${{ secrets.GITHUB_TOKEN }}
222+
- *checkout
223+
- *login-container-registry
266224

267225
- name: Set build arguments
268226
shell: bash

0 commit comments

Comments
 (0)