Skip to content

Commit 059fa11

Browse files
authored
Merge pull request #218 from crazy-max/use-github-builder-runtime
use github-builder-runtime package
2 parents 86f1c02 + bda8667 commit 059fa11

4 files changed

Lines changed: 203 additions & 77 deletions

File tree

.github/workflows/.update-deps.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- sbom
2929
- binfmt
3030
- cosign
31-
- toolkit
31+
- runtime
3232
steps:
3333
-
3434
name: GitHub auth token from GitHub App
@@ -161,26 +161,29 @@ jobs:
161161
};
162162
}
163163
},
164-
toolkit: {
165-
key: 'DOCKER_ACTIONS_TOOLKIT_MODULE',
166-
name: 'actions-toolkit module',
167-
branch: 'deps/docker-actions-toolkit-module',
164+
runtime: {
165+
key: 'RUNTIME_MODULE',
166+
name: 'github-builder-runtime module',
167+
branch: 'deps/docker-github-builder-runtime-module',
168168
files: [
169169
'.github/workflows/build.yml',
170170
'.github/workflows/bake.yml',
171171
'.github/workflows/verify.yml'
172172
],
173-
sourceUrl: 'https://github.com/docker/actions-toolkit/releases/latest',
174-
async resolve({github}) {
175-
const release = await github.rest.repos.getLatestRelease({
176-
owner: 'docker',
177-
repo: 'actions-toolkit'
178-
});
179-
const tag = release.data.tag_name;
180-
const version = stripLeadingV(tag);
173+
sourceUrl: 'https://www.npmjs.com/package/@docker/github-builder-runtime',
174+
async resolve() {
175+
const response = await fetch('https://registry.npmjs.org/@docker%2fgithub-builder-runtime/latest');
176+
if (!response.ok) {
177+
throw new Error(`Unable to resolve latest @docker/github-builder-runtime package: ${response.status} ${response.statusText}`);
178+
}
179+
const payload = await response.json();
180+
const version = payload?.version;
181+
if (!version) {
182+
throw new Error('Unable to resolve latest @docker/github-builder-runtime package version from npm');
183+
}
181184
return {
182-
value: `@docker/actions-toolkit@${version}`,
183-
from: tag,
185+
value: `@docker/github-builder-runtime@${version}`,
186+
from: version,
184187
to: version
185188
};
186189
}

.github/workflows/bake.yml

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,16 @@ env:
161161
BUILDKIT_IMAGE: "moby/buildkit:v0.30.0"
162162
SBOM_IMAGE: "docker/buildkit-syft-scanner:1.11.0"
163163
BINFMT_IMAGE: "tonistiigi/binfmt:qemu-v10.2.1-65"
164-
DOCKER_ACTIONS_TOOLKIT_MODULE: "@docker/actions-toolkit@0.90.0"
164+
RUNTIME_MODULE: "@docker/github-builder-runtime@0.91.0"
165+
RUNTIME_INSTALL_ARGS: |
166+
--loglevel=error
167+
--no-save
168+
--package-lock=false
169+
--ignore-scripts
170+
--omit=dev
171+
--prefer-offline
172+
--fund=false
173+
--audit=false
165174
COSIGN_VERSION: "v3.0.6"
166175
LOCAL_EXPORT_DIR: "/tmp/buildx-output"
167176
MATRIX_SIZE_LIMIT: "20"
@@ -181,19 +190,34 @@ jobs:
181190
name: Install dependencies
182191
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
183192
env:
184-
INPUT_DAT-MODULE: ${{ env.DOCKER_ACTIONS_TOOLKIT_MODULE }}
193+
INPUT_RUNTIME-MODULE: ${{ env.RUNTIME_MODULE }}
194+
INPUT_RUNTIME-INSTALL-ARGS: ${{ env.RUNTIME_INSTALL_ARGS }}
185195
with:
186196
script: |
187-
await exec.exec('npm', ['install', '--prefer-offline', '--ignore-scripts', core.getInput('dat-module')]);
197+
const npmArgs = ['install', ...core.getMultilineInput('runtime-install-args'), core.getInput('runtime-module')];
198+
const maxAttempts = 3;
199+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
200+
const exitCode = await exec.exec('npm', npmArgs, {ignoreReturnCode: true});
201+
if (exitCode === 0) {
202+
return;
203+
}
204+
if (attempt === maxAttempts) {
205+
core.setFailed(`npm install failed after ${maxAttempts} attempts`);
206+
return;
207+
}
208+
const retryDelayMs = attempt * 50;
209+
core.info(`npm install failed with exit code ${exitCode}; retrying in ${retryDelayMs}ms`);
210+
await new Promise(resolve => setTimeout(resolve, retryDelayMs));
211+
}
188212
-
189213
name: Install Cosign
190214
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
191215
env:
192216
INPUT_COSIGN-VERSION: ${{ env.COSIGN_VERSION }}
193217
with:
194218
script: |
195-
const { Cosign } = require('@docker/actions-toolkit/lib/cosign/cosign');
196-
const { Install } = require('@docker/actions-toolkit/lib/cosign/install');
219+
const { Cosign } = require('@docker/github-builder-runtime/lib/cosign/cosign');
220+
const { Install } = require('@docker/github-builder-runtime/lib/cosign/install');
197221
198222
const inpCosignVersion = core.getInput('cosign-version');
199223
@@ -218,8 +242,8 @@ jobs:
218242
${{ env.BINFMT_IMAGE }}
219243
with:
220244
script: |
221-
const { OCI } = require('@docker/actions-toolkit/lib/oci/oci');
222-
const { Sigstore } = require('@docker/actions-toolkit/lib/sigstore/sigstore');
245+
const { OCI } = require('@docker/github-builder-runtime/lib/oci/oci');
246+
const { Sigstore } = require('@docker/github-builder-runtime/lib/sigstore/sigstore');
223247
224248
const sigstore = new Sigstore();
225249
@@ -268,10 +292,10 @@ jobs:
268292
with:
269293
script: |
270294
const os = require('os');
271-
const { Bake } = require('@docker/actions-toolkit/lib/buildx/bake');
272-
const { Build } = require('@docker/actions-toolkit/lib/buildx/build');
273-
const { GitHub } = require('@docker/actions-toolkit/lib/github/github');
274-
const { Util } = require('@docker/actions-toolkit/lib/util');
295+
const { Bake } = require('@docker/github-builder-runtime/lib/buildx/bake');
296+
const { Build } = require('@docker/github-builder-runtime/lib/buildx/build');
297+
const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
298+
const { Util } = require('@docker/github-builder-runtime/lib/util');
275299
276300
const inpSbomImage = core.getInput('sbom-image');
277301
const inpMatrixSizeLimit = parseInt(core.getInput('matrix-size-limit'), 10);
@@ -592,15 +616,25 @@ jobs:
592616
name: Install dependencies
593617
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
594618
env:
595-
INPUT_DAT-MODULE: ${{ env.DOCKER_ACTIONS_TOOLKIT_MODULE }}
619+
INPUT_RUNTIME-MODULE: ${{ env.RUNTIME_MODULE }}
620+
INPUT_RUNTIME-INSTALL-ARGS: ${{ env.RUNTIME_INSTALL_ARGS }}
596621
with:
597622
script: |
598-
await exec.exec('npm', [
599-
'install',
600-
'--prefer-offline',
601-
'--ignore-scripts',
602-
core.getInput('dat-module')
603-
]);
623+
const npmArgs = ['install', ...core.getMultilineInput('runtime-install-args'), core.getInput('runtime-module')];
624+
const maxAttempts = 3;
625+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
626+
const exitCode = await exec.exec('npm', npmArgs, {ignoreReturnCode: true});
627+
if (exitCode === 0) {
628+
return;
629+
}
630+
if (attempt === maxAttempts) {
631+
core.setFailed(`npm install failed after ${maxAttempts} attempts`);
632+
return;
633+
}
634+
const retryDelayMs = attempt * 50;
635+
core.info(`npm install failed with exit code ${exitCode}; retrying in ${retryDelayMs}ms`);
636+
await new Promise(resolve => setTimeout(resolve, retryDelayMs));
637+
}
604638
-
605639
name: Docker meta
606640
id: meta
@@ -712,9 +746,9 @@ jobs:
712746
const os = require('os');
713747
const path = require('path');
714748
715-
const { Buildx } = require('@docker/actions-toolkit/lib/buildx/buildx');
716-
const { Cosign } = require('@docker/actions-toolkit/lib/cosign/cosign');
717-
const { Install } = require('@docker/actions-toolkit/lib/cosign/install');
749+
const { Buildx } = require('@docker/github-builder-runtime/lib/buildx/buildx');
750+
const { Cosign } = require('@docker/github-builder-runtime/lib/cosign/cosign');
751+
const { Install } = require('@docker/github-builder-runtime/lib/cosign/install');
718752
719753
const inpCosignVersion = core.getInput('cosign-version');
720754
const inpBuilderName = core.getInput('builder-name');
@@ -782,9 +816,9 @@ jobs:
782816
with:
783817
script: |
784818
const os = require('os');
785-
const { Build } = require('@docker/actions-toolkit/lib/buildx/build');
786-
const { GitHub } = require('@docker/actions-toolkit/lib/github/github');
787-
const { Util } = require('@docker/actions-toolkit/lib/util');
819+
const { Build } = require('@docker/github-builder-runtime/lib/buildx/build');
820+
const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
821+
const { Util } = require('@docker/github-builder-runtime/lib/util');
788822
789823
const inpPlatform = core.getInput('platform');
790824
const platformPairSuffix = inpPlatform ? `-${inpPlatform.replace(/\//g, '-')}` : '';
@@ -968,7 +1002,7 @@ jobs:
9681002
INPUT_IMAGE-DIGEST: ${{ steps.get-image-digest.outputs.digest }}
9691003
with:
9701004
script: |
971-
const { Sigstore } = require('@docker/actions-toolkit/lib/sigstore/sigstore');
1005+
const { Sigstore } = require('@docker/github-builder-runtime/lib/sigstore/sigstore');
9721006
9731007
const inpImageNames = core.getMultilineInput('image-names');
9741008
const inpImageDigest = core.getInput('image-digest');
@@ -1004,7 +1038,7 @@ jobs:
10041038
with:
10051039
script: |
10061040
const path = require('path');
1007-
const { Sigstore } = require('@docker/actions-toolkit/lib/sigstore/sigstore');
1041+
const { Sigstore } = require('@docker/github-builder-runtime/lib/sigstore/sigstore');
10081042
const inplocalExportDir = core.getInput('local-output-dir');
10091043
10101044
const sigstore = new Sigstore();
@@ -1086,10 +1120,25 @@ jobs:
10861120
name: Install dependencies
10871121
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
10881122
env:
1089-
INPUT_DAT-MODULE: ${{ env.DOCKER_ACTIONS_TOOLKIT_MODULE }}
1123+
INPUT_RUNTIME-MODULE: ${{ env.RUNTIME_MODULE }}
1124+
INPUT_RUNTIME-INSTALL-ARGS: ${{ env.RUNTIME_INSTALL_ARGS }}
10901125
with:
10911126
script: |
1092-
await exec.exec('npm', ['install', '--prefer-offline', '--ignore-scripts', core.getInput('dat-module')]);
1127+
const npmArgs = ['install', ...core.getMultilineInput('runtime-install-args'), core.getInput('runtime-module')];
1128+
const maxAttempts = 3;
1129+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1130+
const exitCode = await exec.exec('npm', npmArgs, {ignoreReturnCode: true});
1131+
if (exitCode === 0) {
1132+
return;
1133+
}
1134+
if (attempt === maxAttempts) {
1135+
core.setFailed(`npm install failed after ${maxAttempts} attempts`);
1136+
return;
1137+
}
1138+
const retryDelayMs = attempt * 50;
1139+
core.info(`npm install failed with exit code ${exitCode}; retrying in ${retryDelayMs}ms`);
1140+
await new Promise(resolve => setTimeout(resolve, retryDelayMs));
1141+
}
10931142
-
10941143
name: Docker meta
10951144
id: meta
@@ -1133,7 +1182,7 @@ jobs:
11331182
INPUT_META-ANNOTATIONS: ${{ steps.meta.outputs.annotations }}
11341183
with:
11351184
script: |
1136-
const { ImageTools } = require('@docker/actions-toolkit/lib/buildx/imagetools');
1185+
const { ImageTools } = require('@docker/github-builder-runtime/lib/buildx/imagetools');
11371186
11381187
const inpPush = core.getBooleanInput('push');
11391188
const inpImageNames = core.getMultilineInput('image-names');

0 commit comments

Comments
 (0)