Skip to content

Commit 72f27ea

Browse files
author
Nicola Lunghi
committed
Modify the github workflow to automatically build all targets
1 parent d6dcf2b commit 72f27ea

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.github/workflows/CI.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
jobs:
23+
extract-targets:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
targets: ${{ steps.extract.outputs.targets }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Extract targets as JSON array
30+
id: extract
31+
uses: dcarbone/install-jq-action@v2
32+
- name: Get targets from bake file
33+
id: get-targets
34+
run: |
35+
TARGETS=$(docker buildx bake --file docker-bake.hcl --print | jq -c '[.target | keys[] | select(. != "default")]')
36+
echo "targets=$TARGETS" | tee -a ${GITHUB_OUTPUT}
37+
2338
build:
39+
needs: extract-targets
40+
runs-on: ubuntu-latest
2441
strategy:
2542
matrix:
26-
target: [ "all", "20", "19", "18", "17", "16", "16-alpine", "15", "14", "13", "12", "11", "10", "9", "8", "7"]
27-
runs-on: ubuntu-latest
43+
target: ${{ fromJson(needs.extract-targets.outputs.targets) }}
2844
steps:
2945
- uses: actions/checkout@v4
3046

docker-bake.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ group "default" {
1717
"8", "8-alpine",
1818
"7", "7-alpine",
1919
]
20+
}
2021
# ---- Alpine targets ----
2122
target "20-alpine" {
2223
dockerfile = "Dockerfile.alpine"
@@ -199,7 +200,6 @@ target "7-alpine" {
199200
]
200201
platforms = ["linux/amd64", "linux/arm64"]
201202
}
202-
}
203203

204204
# ---- variables ----
205205
variable "DOCKER_REPO" {

0 commit comments

Comments
 (0)