Skip to content

Commit a6e198a

Browse files
authored
Merge pull request #3301 from crazy-max/ci-matrix-subaction
ci(validate): use matrix subaction
2 parents 2d65b12 + 159a68c commit a6e198a

File tree

1 file changed

+9
-46
lines changed

1 file changed

+9
-46
lines changed

.github/workflows/validate.yml

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,20 @@ jobs:
3333
prepare:
3434
runs-on: ubuntu-24.04
3535
outputs:
36-
includes: ${{ steps.matrix.outputs.includes }}
36+
includes: ${{ steps.generate.outputs.matrix }}
3737
steps:
3838
-
3939
name: Checkout
4040
uses: actions/checkout@v5
4141
-
42-
name: Matrix
43-
id: matrix
44-
uses: actions/github-script@v7
42+
name: Generate matrix
43+
id: generate
44+
uses: docker/bake-action/subaction/matrix@v6
4545
with:
46-
script: |
47-
let def = {};
48-
await core.group(`Parsing definition`, async () => {
49-
const printEnv = Object.assign({}, process.env, {
50-
GOLANGCI_LINT_MULTIPLATFORM: process.env.GITHUB_REPOSITORY === 'docker/buildx' ? '1' : ''
51-
});
52-
const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', 'validate', '--print'], {
53-
ignoreReturnCode: true,
54-
env: printEnv
55-
});
56-
if (resPrint.stderr.length > 0 && resPrint.exitCode != 0) {
57-
throw new Error(res.stderr);
58-
}
59-
def = JSON.parse(resPrint.stdout.trim());
60-
});
61-
await core.group(`Generating matrix`, async () => {
62-
const includes = [];
63-
for (const targetName of Object.keys(def.target)) {
64-
const target = def.target[targetName];
65-
if (target.platforms && target.platforms.length > 0) {
66-
target.platforms.forEach(platform => {
67-
includes.push({
68-
target: targetName,
69-
platform: platform
70-
});
71-
});
72-
} else {
73-
includes.push({
74-
target: targetName
75-
});
76-
}
77-
}
78-
core.info(JSON.stringify(includes, null, 2));
79-
core.setOutput('includes', JSON.stringify(includes));
80-
});
46+
target: validate
47+
fields: platforms
48+
env:
49+
GOLANGCI_LINT_MULTIPLATFORM: ${{ github.repository == 'docker/buildx' && '1' || '' }}
8150

8251
validate:
8352
runs-on: ubuntu-24.04
@@ -88,12 +57,6 @@ jobs:
8857
matrix:
8958
include: ${{ fromJson(needs.prepare.outputs.includes) }}
9059
steps:
91-
-
92-
name: Prepare
93-
run: |
94-
if [ "$GITHUB_REPOSITORY" = "docker/buildx" ]; then
95-
echo "GOLANGCI_LINT_MULTIPLATFORM=1" >> $GITHUB_ENV
96-
fi
9760
-
9861
name: Set up Docker Buildx
9962
uses: docker/setup-buildx-action@v3
@@ -107,4 +70,4 @@ jobs:
10770
with:
10871
targets: ${{ matrix.target }}
10972
set: |
110-
*.platform=${{ matrix.platform }}
73+
*.platform=${{ matrix.platforms }}

0 commit comments

Comments
 (0)