From 159a68cbb89eecfd974940a6fa2bfcbe72d90b7e Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:14:50 +0200 Subject: [PATCH] ci(validate): use matrix subaction Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/validate.yml | 55 ++++++---------------------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index d0be9034..9803d452 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -33,51 +33,20 @@ jobs: prepare: runs-on: ubuntu-24.04 outputs: - includes: ${{ steps.matrix.outputs.includes }} + includes: ${{ steps.generate.outputs.matrix }} steps: - name: Checkout uses: actions/checkout@v5 - - name: Matrix - id: matrix - uses: actions/github-script@v7 + name: Generate matrix + id: generate + uses: docker/bake-action/subaction/matrix@v6 with: - script: | - let def = {}; - await core.group(`Parsing definition`, async () => { - const printEnv = Object.assign({}, process.env, { - GOLANGCI_LINT_MULTIPLATFORM: process.env.GITHUB_REPOSITORY === 'docker/buildx' ? '1' : '' - }); - const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', 'validate', '--print'], { - ignoreReturnCode: true, - env: printEnv - }); - if (resPrint.stderr.length > 0 && resPrint.exitCode != 0) { - throw new Error(res.stderr); - } - def = JSON.parse(resPrint.stdout.trim()); - }); - await core.group(`Generating matrix`, async () => { - const includes = []; - for (const targetName of Object.keys(def.target)) { - const target = def.target[targetName]; - if (target.platforms && target.platforms.length > 0) { - target.platforms.forEach(platform => { - includes.push({ - target: targetName, - platform: platform - }); - }); - } else { - includes.push({ - target: targetName - }); - } - } - core.info(JSON.stringify(includes, null, 2)); - core.setOutput('includes', JSON.stringify(includes)); - }); + target: validate + fields: platforms + env: + GOLANGCI_LINT_MULTIPLATFORM: ${{ github.repository == 'docker/buildx' && '1' || '' }} validate: runs-on: ubuntu-24.04 @@ -88,12 +57,6 @@ jobs: matrix: include: ${{ fromJson(needs.prepare.outputs.includes) }} steps: - - - name: Prepare - run: | - if [ "$GITHUB_REPOSITORY" = "docker/buildx" ]; then - echo "GOLANGCI_LINT_MULTIPLATFORM=1" >> $GITHUB_ENV - fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -107,4 +70,4 @@ jobs: with: targets: ${{ matrix.target }} set: | - *.platform=${{ matrix.platform }} + *.platform=${{ matrix.platforms }}