Compare commits

...

35 Commits

Author SHA1 Message Date
CrazyMax
4fd812986e
Merge pull request #312 from docker/dependabot/npm_and_yarn/undici-5.28.4
build(deps): bump undici from 5.28.3 to 5.28.4
2024-07-04 00:59:46 +02:00
CrazyMax
3386dc4251
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-04 00:57:40 +02:00
dependabot[bot]
d191aef416
build(deps): bump undici from 5.28.3 to 5.28.4
Bumps [undici](https://github.com/nodejs/undici) from 5.28.3 to 5.28.4.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.28.3...v5.28.4)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-03 22:39:48 +00:00
CrazyMax
f686054aab
Merge pull request #338 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.31.0
build(deps): bump @docker/actions-toolkit from 0.23.0 to 0.31.0
2024-07-04 00:36:59 +02:00
CrazyMax
78547859d7
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-04 00:28:28 +02:00
CrazyMax
830928c706
fix builder type path
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-04 00:28:27 +02:00
dependabot[bot]
26d2aec173
build(deps): bump @docker/actions-toolkit from 0.23.0 to 0.31.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.23.0 to 0.31.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.23.0...v0.31.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-03 18:22:10 +00:00
CrazyMax
ab17e3ec80
Merge pull request #339 from crazy-max/missing-types-jsyaml
missing types for js-yaml
2024-07-03 20:21:11 +02:00
CrazyMax
d79cb80903
missing types for js-yaml
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-03 20:17:56 +02:00
CrazyMax
13cf78894f
Merge pull request #326 from docker/dependabot/npm_and_yarn/uuid-10.0.0
build(deps): bump uuid from 9.0.1 to 10.0.0
2024-07-03 13:50:25 +02:00
CrazyMax
0e592087a0
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-03 13:33:18 +02:00
CrazyMax
47032b9b53
missing types for uuid
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-03 13:33:17 +02:00
CrazyMax
abe89fb761
Merge pull request #329 from docker/dependabot/npm_and_yarn/braces-3.0.3
build(deps): bump braces from 3.0.2 to 3.0.3
2024-06-20 18:01:53 +02:00
CrazyMax
e027232c25
Merge pull request #332 from docker/dependabot/github_actions/docker/bake-action-5
build(deps): bump docker/bake-action from 4 to 5
2024-06-20 17:59:29 +02:00
CrazyMax
5d9397e7ca
Merge pull request #331 from docker/dependabot/github_actions/docker/build-push-action-6
build(deps): bump docker/build-push-action from 5 to 6
2024-06-20 17:59:12 +02:00
dependabot[bot]
e9ab4c6a14
build(deps): bump docker/bake-action from 4 to 5
Bumps [docker/bake-action](https://github.com/docker/bake-action) from 4 to 5.
- [Release notes](https://github.com/docker/bake-action/releases)
- [Commits](https://github.com/docker/bake-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/bake-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-18 04:09:56 +00:00
dependabot[bot]
748835b452
build(deps): bump docker/build-push-action from 5 to 6
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-18 04:09:53 +00:00
dependabot[bot]
554c728605
build(deps): bump braces from 3.0.2 to 3.0.3
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-16 13:37:42 +00:00
dependabot[bot]
1c1261e632
build(deps): bump uuid from 9.0.1 to 10.0.0
Bumps [uuid](https://github.com/uuidjs/uuid) from 9.0.1 to 10.0.0.
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v9.0.1...v10.0.0)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-10 04:44:49 +00:00
CrazyMax
5138f76647
Merge pull request #322 from crazy-max/update-dev-deps
chore: update dev dependencies
2024-05-15 14:01:13 +02:00
CrazyMax
eddcf46655
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-05-15 13:58:48 +02:00
CrazyMax
2740b29678
chore: update dev dependencies
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-05-15 13:57:47 +02:00
CrazyMax
1113efed2b
Merge pull request #321 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.23.0
build(deps): bump @docker/actions-toolkit from 0.20.0 to 0.23.0
2024-05-15 12:11:09 +02:00
CrazyMax
8a2a7ad780
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-05-15 12:09:16 +02:00
dependabot[bot]
e3c7deb79b
build(deps): bump @docker/actions-toolkit from 0.20.0 to 0.23.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.20.0 to 0.23.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.20.0...v0.23.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-15 04:12:14 +00:00
CrazyMax
be3701b211
Merge pull request #319 from crazy-max/update-yarn
update to yarn 3.6.3
2024-05-07 15:48:31 +02:00
CrazyMax
e2ed622d10
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-05-07 15:46:36 +02:00
CrazyMax
b73b950903
chore: add plugin-interactive-tools yarn pkg
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-05-07 15:44:37 +02:00
CrazyMax
157d6d0106
update to yarn 3.6.3
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-05-07 15:43:51 +02:00
Tõnis Tiigi
a530e948ad
Merge pull request #315 from crazy-max/fix-err-output
throw error message instead of exit code
2024-04-15 16:53:40 -07:00
CrazyMax
28ecb964cd
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-04-12 12:22:12 +02:00
CrazyMax
dc25d8b2ee
throw error message instead of exit code
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-04-12 12:22:01 +02:00
Tõnis Tiigi
d70bba72b1
Merge pull request #307 from crazy-max/bump-toolkit
bump @docker/actions-toolkit from 0.19.0 to 0.20.0
2024-04-04 09:52:13 -07:00
CrazyMax
7638634cb7
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-04-02 10:45:45 +02:00
CrazyMax
c68420fe0b
bump @docker/actions-toolkit from 0.19.0 to 0.20.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-04-02 10:44:53 +02:00
19 changed files with 9697 additions and 4319 deletions

View File

@ -1,2 +1,12 @@
/coverage /coverage
/node_modules
# Dependency directories
node_modules/
jspm_packages/
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

2
.gitattributes vendored
View File

@ -1,2 +1,4 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
/dist/** linguist-generated=true /dist/** linguist-generated=true
/lib/** linguist-generated=true /lib/** linguist-generated=true

View File

@ -108,7 +108,7 @@ jobs:
buildkitd-flags: --debug buildkitd-flags: --debug
- -
name: Build name: Build
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64,linux/ppc64le platforms: linux/amd64,linux/arm64,linux/ppc64le
@ -254,7 +254,7 @@ jobs:
buildkitd-config: /tmp/buildkitd.toml buildkitd-config: /tmp/buildkitd.toml
- -
name: Build name: Build
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .
@ -281,7 +281,7 @@ jobs:
mirrors = ["mirror.gcr.io"] mirrors = ["mirror.gcr.io"]
- -
name: Build name: Build
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .

View File

@ -23,7 +23,7 @@ jobs:
uses: ./ uses: ./
- -
name: Test name: Test
uses: docker/bake-action@v4 uses: docker/bake-action@v5
with: with:
targets: test targets: test
- -

View File

@ -40,6 +40,6 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- -
name: Validate name: Validate
uses: docker/bake-action@v4 uses: docker/bake-action@v5
with: with:
targets: ${{ matrix.target }} targets: ${{ matrix.target }}

71
.gitignore vendored
View File

@ -1,12 +1,5 @@
/.dev # https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
node_modules
lib
# Jetbrains
/.idea
/*.iml
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs # Logs
logs logs
*.log *.log
@ -14,6 +7,7 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log* lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html) # Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@ -24,34 +18,14 @@ pids
*.seed *.seed
*.pid.lock *.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul # Coverage directory used by tools like istanbul
coverage coverage
*.lcov *.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories # Dependency directories
node_modules/
jspm_packages/ jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache # TypeScript cache
*.tsbuildinfo *.tsbuildinfo
@ -61,36 +35,19 @@ typings/
# Optional eslint cache # Optional eslint cache
.eslintcache .eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file # Yarn Integrity file
.yarn-integrity .yarn-integrity
# dotenv environment variables file # dotenv environment variable files
.env .env
.env.test .env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/) # yarn v2
.cache .yarn/cache
.yarn/unplugged
# next.js build output .yarn/build-state.yml
.next .yarn/install-state.gz
.pnp.*
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/

6
.prettierignore Normal file
View File

@ -0,0 +1,6 @@
# Dependency directories
node_modules/
jspm_packages/
# yarn v2
.yarn/

File diff suppressed because one or more lines are too long

13
.yarnrc.yml Normal file
View File

@ -0,0 +1,13 @@
logFilters:
- code: YN0013
level: discard
- code: YN0019
level: discard
- code: YN0076
level: discard
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

View File

@ -6,7 +6,7 @@ import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
import {Context} from '@docker/actions-toolkit/lib/context'; import {Context} from '@docker/actions-toolkit/lib/context';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {Node} from '@docker/actions-toolkit/lib/types/builder'; import {Node} from '@docker/actions-toolkit/lib/types/buildx/builder';
import * as context from '../src/context'; import * as context from '../src/context';

View File

@ -5,9 +5,16 @@ ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine AS base FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git RUN apk add --no-cache cpio findutils git
WORKDIR /src WORKDIR /src
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache <<EOT
corepack enable
yarn --version
yarn config set --home enableTelemetry 0
EOT
FROM base AS deps FROM base AS deps
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn install && mkdir /vendor && cp yarn.lock /vendor yarn install && mkdir /vendor && cp yarn.lock /vendor
@ -16,18 +23,19 @@ COPY --from=deps /vendor /
FROM deps AS vendor-validate FROM deps AS vendor-validate
RUN --mount=type=bind,target=.,rw <<EOT RUN --mount=type=bind,target=.,rw <<EOT
set -e set -e
git add -A git add -A
cp -rf /vendor/* . cp -rf /vendor/* .
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"' echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
git status --porcelain -- yarn.lock git status --porcelain -- yarn.lock
exit 1 exit 1
fi fi
EOT EOT
FROM deps AS build FROM deps AS build
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run build && mkdir /out && cp -Rf dist /out/ yarn run build && mkdir /out && cp -Rf dist /out/
@ -36,34 +44,35 @@ COPY --from=build /out /
FROM build AS build-validate FROM build AS build-validate
RUN --mount=type=bind,target=.,rw <<EOT RUN --mount=type=bind,target=.,rw <<EOT
set -e set -e
git add -A git add -A
cp -rf /out/* . cp -rf /out/* .
if [ -n "$(git status --porcelain -- dist)" ]; then if [ -n "$(git status --porcelain -- dist)" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"' echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
git status --porcelain -- dist git status --porcelain -- dist
exit 1 exit 1
fi fi
EOT EOT
FROM deps AS format FROM deps AS format
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run format \ yarn run format \
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
FROM scratch AS format-update FROM scratch AS format-update
COPY --from=format /out / COPY --from=format /out /
FROM deps AS lint FROM deps AS lint
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run lint yarn run lint
FROM deps AS test FROM deps AS test
ENV RUNNER_TEMP=/tmp/github_runner
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run test --coverage --coverageDirectory=/tmp/coverage yarn run test --coverage --coverageDirectory=/tmp/coverage

87
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

2044
dist/licenses.txt generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ group "default" {
} }
group "pre-checkin" { group "pre-checkin" {
targets = ["vendor-update", "format", "build"] targets = ["vendor", "format", "build"]
} }
group "validate" { group "validate" {
@ -34,7 +34,7 @@ target "lint" {
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "vendor-update" { target "vendor" {
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "vendor-update" target = "vendor-update"
output = ["."] output = ["."]

View File

@ -1,17 +1,16 @@
{ {
"name": "docker-setup-buildx", "name": "docker-setup-buildx",
"description": "Set up Docker Buildx", "description": "Set up Docker Buildx",
"main": "lib/main.js", "main": "src/main.ts",
"scripts": { "scripts": {
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt", "build": "ncc build --source-map --minify --license licenses.txt",
"lint": "yarn run prettier && yarn run eslint", "lint": "yarn run prettier && yarn run eslint",
"format": "yarn run prettier:fix && yarn run eslint:fix", "format": "yarn run prettier:fix && yarn run eslint:fix",
"eslint": "eslint --max-warnings=0 .", "eslint": "eslint --max-warnings=0 .",
"eslint:fix": "eslint --fix .", "eslint:fix": "eslint --fix .",
"prettier": "prettier --check \"./**/*.ts\"", "prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"", "prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest", "test": "jest"
"all": "yarn run build && yarn run format && yarn test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -24,26 +23,28 @@
], ],
"author": "Docker Inc.", "author": "Docker Inc.",
"license": "Apache-2.0", "license": "Apache-2.0",
"packageManager": "yarn@3.6.3",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1", "@docker/actions-toolkit": "^0.31.0",
"@docker/actions-toolkit": "^0.19.0",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"uuid": "^9.0.1" "uuid": "^10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.5.9", "@types/js-yaml": "^4.0.9",
"@typescript-eslint/eslint-plugin": "^6.6.0", "@types/node": "^20.12.12",
"@typescript-eslint/parser": "^6.6.0", "@types/uuid": "^10.0.0",
"@vercel/ncc": "^0.38.0", "@typescript-eslint/eslint-plugin": "^7.9.0",
"eslint": "^8.48.0", "@typescript-eslint/parser": "^7.9.0",
"eslint-config-prettier": "^9.0.0", "@vercel/ncc": "^0.38.1",
"eslint-plugin-jest": "^27.2.3", "eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.0.0", "eslint-config-prettier": "^9.1.0",
"jest": "^29.6.4", "eslint-plugin-jest": "^28.5.0",
"prettier": "^3.0.3", "eslint-plugin-prettier": "^5.1.3",
"ts-jest": "^29.1.1", "jest": "^29.7.0",
"ts-node": "^10.9.1", "prettier": "^3.2.5",
"typescript": "^5.2.2" "ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
} }
} }

View File

@ -1,9 +1,11 @@
import * as uuid from 'uuid'; import * as uuid from 'uuid';
import * as core from '@actions/core'; import * as core from '@actions/core';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Util} from '@docker/actions-toolkit/lib/util'; import {Util} from '@docker/actions-toolkit/lib/util';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {Node} from '@docker/actions-toolkit/lib/types/builder';
import {Node} from '@docker/actions-toolkit/lib/types/buildx/builder';
export const builderNodeEnvPrefix = 'BUILDER_NODE'; export const builderNodeEnvPrefix = 'BUILDER_NODE';

View File

@ -1,14 +1,16 @@
import * as fs from 'fs'; import * as fs from 'fs';
import * as yaml from 'js-yaml'; import * as yaml from 'js-yaml';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as actionsToolkit from '@docker/actions-toolkit'; import * as actionsToolkit from '@docker/actions-toolkit';
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx'; import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder'; import {Builder} from '@docker/actions-toolkit/lib/buildx/builder';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Exec} from '@docker/actions-toolkit/lib/exec';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {Util} from '@docker/actions-toolkit/lib/util'; import {Util} from '@docker/actions-toolkit/lib/util';
import {Node} from '@docker/actions-toolkit/lib/types/builder';
import {Node} from '@docker/actions-toolkit/lib/types/buildx/builder';
import * as context from './context'; import * as context from './context';
import * as stateHelper from './state-helper'; import * as stateHelper from './state-helper';
@ -77,7 +79,13 @@ actionsToolkit.run(
inputs.driverOpts = [...inputs.driverOpts, ...certsDriverOpts]; inputs.driverOpts = [...inputs.driverOpts, ...certsDriverOpts];
} }
const createCmd = await toolkit.buildx.getCommand(await context.getCreateArgs(inputs, toolkit)); const createCmd = await toolkit.buildx.getCommand(await context.getCreateArgs(inputs, toolkit));
await exec.exec(createCmd.command, createCmd.args); await Exec.getExecOutput(createCmd.command, createCmd.args, {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
}); });
} }
@ -95,7 +103,13 @@ actionsToolkit.run(
node['driver-opts'] = [...(node['driver-opts'] || []), ...certsDriverOpts]; node['driver-opts'] = [...(node['driver-opts'] || []), ...certsDriverOpts];
} }
const appendCmd = await toolkit.buildx.getCommand(await context.getAppendArgs(inputs, node, toolkit)); const appendCmd = await toolkit.buildx.getCommand(await context.getAppendArgs(inputs, node, toolkit));
await exec.exec(appendCmd.command, appendCmd.args); await Exec.getExecOutput(appendCmd.command, appendCmd.args, {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(`Failed to append node ${node.name}: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
}
});
nodeIndex++; nodeIndex++;
} }
}); });
@ -103,7 +117,13 @@ actionsToolkit.run(
await core.group(`Booting builder`, async () => { await core.group(`Booting builder`, async () => {
const inspectCmd = await toolkit.buildx.getCommand(await context.getInspectArgs(inputs, toolkit)); const inspectCmd = await toolkit.buildx.getCommand(await context.getInspectArgs(inputs, toolkit));
await exec.exec(inspectCmd.command, inspectCmd.args); await Exec.getExecOutput(inspectCmd.command, inspectCmd.args, {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
}); });
if (inputs.install) { if (inputs.install) {
@ -112,7 +132,13 @@ actionsToolkit.run(
} }
await core.group(`Setting buildx as default builder`, async () => { await core.group(`Setting buildx as default builder`, async () => {
const installCmd = await toolkit.buildx.getCommand(['install']); const installCmd = await toolkit.buildx.getCommand(['install']);
await exec.exec(installCmd.command, installCmd.args); await Exec.getExecOutput(installCmd.command, installCmd.args, {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
}); });
} }
@ -155,15 +181,13 @@ actionsToolkit.run(
async () => { async () => {
if (stateHelper.IsDebug && stateHelper.containerName.length > 0) { if (stateHelper.IsDebug && stateHelper.containerName.length > 0) {
await core.group(`BuildKit container logs`, async () => { await core.group(`BuildKit container logs`, async () => {
await exec await Exec.getExecOutput('docker', ['logs', `${stateHelper.containerName}`], {
.getExecOutput('docker', ['logs', `${stateHelper.containerName}`], { ignoreReturnCode: true
ignoreReturnCode: true }).then(res => {
}) if (res.stderr.length > 0 && res.exitCode != 0) {
.then(res => { core.warning(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
if (res.stderr.length > 0 && res.exitCode != 0) { }
core.warning(res.stderr.trim()); });
}
});
}); });
} }
@ -177,15 +201,13 @@ actionsToolkit.run(
const builder = new Builder({buildx: buildx}); const builder = new Builder({buildx: buildx});
if (await builder.exists(stateHelper.builderName)) { if (await builder.exists(stateHelper.builderName)) {
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]); const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
await exec await Exec.getExecOutput(rmCmd.command, rmCmd.args, {
.getExecOutput(rmCmd.command, rmCmd.args, { ignoreReturnCode: true
ignoreReturnCode: true }).then(res => {
}) if (res.stderr.length > 0 && res.exitCode != 0) {
.then(res => { core.warning(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
if (res.stderr.length > 0 && res.exitCode != 0) { }
core.warning(res.stderr.trim()); });
}
});
} else { } else {
core.info(`${stateHelper.builderName} does not exist`); core.info(`${stateHelper.builderName} does not exist`);
} }

11060
yarn.lock

File diff suppressed because it is too large Load Diff