mirror of https://github.com/docker/buildx.git
ci(validate): use matrix subaction
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
2d65b12a65
commit
159a68cbb8
|
|
@ -33,51 +33,20 @@ jobs:
|
||||||
prepare:
|
prepare:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
outputs:
|
outputs:
|
||||||
includes: ${{ steps.matrix.outputs.includes }}
|
includes: ${{ steps.generate.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Matrix
|
name: Generate matrix
|
||||||
id: matrix
|
id: generate
|
||||||
uses: actions/github-script@v7
|
uses: docker/bake-action/subaction/matrix@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
target: validate
|
||||||
let def = {};
|
fields: platforms
|
||||||
await core.group(`Parsing definition`, async () => {
|
env:
|
||||||
const printEnv = Object.assign({}, process.env, {
|
GOLANGCI_LINT_MULTIPLATFORM: ${{ github.repository == 'docker/buildx' && '1' || '' }}
|
||||||
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));
|
|
||||||
});
|
|
||||||
|
|
||||||
validate:
|
validate:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
|
|
@ -88,12 +57,6 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
include: ${{ fromJson(needs.prepare.outputs.includes) }}
|
include: ${{ fromJson(needs.prepare.outputs.includes) }}
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Prepare
|
|
||||||
run: |
|
|
||||||
if [ "$GITHUB_REPOSITORY" = "docker/buildx" ]; then
|
|
||||||
echo "GOLANGCI_LINT_MULTIPLATFORM=1" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
@ -107,4 +70,4 @@ jobs:
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
set: |
|
set: |
|
||||||
*.platform=${{ matrix.platform }}
|
*.platform=${{ matrix.platforms }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue