From cb02c5f3d1805a59bf5709b14f979180978a3c8c Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 2 Apr 2021 01:19:14 +0200 Subject: [PATCH] Enhance workflow Signed-off-by: CrazyMax --- .dockerignore | 2 + .github/CONTRIBUTING.md | 33 +++++---------- .github/ISSUE_TEMPLATE/bug_report.md | 3 +- .github/setup-buildx-action.png | Bin 4607 -> 5172 bytes .github/workflows/ci.yml | 16 +++---- .github/workflows/test.yml | 36 ++++++---------- Dockerfile | 52 ----------------------- dist/index.js | 18 ++++---- docker-bake.hcl | 61 +++++++++++++++++++-------- hack/build.Dockerfile | 42 ++++++++++++++++++ hack/shell | 6 --- hack/test.Dockerfile | 23 ++++++++++ hack/vendor.Dockerfile | 23 ++++++++++ src/buildx.ts | 6 +-- src/main.ts | 12 +++--- 15 files changed, 184 insertions(+), 149 deletions(-) create mode 100644 .dockerignore delete mode 100644 Dockerfile create mode 100644 hack/build.Dockerfile delete mode 100755 hack/shell create mode 100644 hack/test.Dockerfile create mode 100644 hack/vendor.Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ccc2930 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/coverage +/node_modules diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 51231bf..37dca54 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,35 +2,24 @@ Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. -Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE). +Contributions to this project are [released](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license) +to the public under the [project's open source license](LICENSE). ## Submitting a pull request 1. [Fork](https://github.com/docker/setup-buildx-action/fork) and clone the repository 2. Configure and install the dependencies: `yarn install` 3. Create a new branch: `git checkout -b my-branch-name` -4. Make your change, add tests, and make sure the tests still pass -5. Run pre-checkin: `yarn run pre-checkin` -6. Push to your fork and [submit a pull request](https://github.com/docker/setup-buildx-action/compare) -7. Pat yourself on the back and wait for your pull request to be reviewed and merged. - -## Container based developer flow - -If you don't want to maintain a Node developer environment that fits this project you can use containerized commands instead of invoking yarn directly. - -``` -# format code and build javascript artifacts -docker buildx bake pre-checkin - -# validate all code has correctly formatted and built -docker buildx bake validate - -# run tests -docker buildx bake test -``` +4. Make your changes +5. Make sure the tests pass: `docker buildx bake test` +6. Format code and build javascript artifacts: `docker buildx bake pre-checkin` +7. Validate all code has correctly formatted and built: `docker buildx bake validate` +8. Push to your fork and [submit a pull request](https://github.com/docker/setup-buildx-action/compare) +9. Pat your self on the back and wait for your pull request to be reviewed and merged. Here are a few things you can do that will increase the likelihood of your pull request being accepted: +- Write tests. - Make sure the `README.md` and any other relevant **documentation are kept up-to-date**. - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as **separate pull requests**. @@ -39,5 +28,5 @@ Here are a few things you can do that will increase the likelihood of your pull ## Resources - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) -- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) -- [GitHub Help](https://help.github.com) +- [Using Pull Requests](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests) +- [GitHub Help](https://docs.github.com/en) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1c2136d..d50d109 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,4 +30,5 @@ about: Create a report to help us improve ### Logs -> Download the [log file of your build](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#downloading-logs) and [attach it](https://help.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue. +> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs) +> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue. diff --git a/.github/setup-buildx-action.png b/.github/setup-buildx-action.png index 86fe6d398ef80401094d23d4db1c314d681fa01d..72fbeda9869cb5331ee45966234b320a5e03b11f 100644 GIT binary patch literal 5172 zcmYjUby$?!^Izgp(%oGWyW|2(cMFRG3xbGCDj>OlNQfW}0!s+eQnIvwAgOeNbW2M} z$4cyPz4v~f-<>~Z-se5f%zQpG=gf0Xl<_@nG7@GI002OytD|880N}#0-#>`(u)6k0 ztquUdNia5eph-+hNzcL^gUlu-Rgos8v_-nxLMUNH7-CXEeI80;9vC+%B{8Xc-`FfM z#68AIML#H;gOpO*DVqZtp-|L>fC|PS-D84aw#aM*GTRmzp`bh#(j@0z*eiNoTzngN&eOaR9|*U|4sgy9En3EIv)oT1&48QxT}8P_#(Tg4Gy$ zn|x6GV)9tNMaHZg3wK|JgRe5TZ~d%Ze40KqqOU$YJT4Uhg(Z*8(kqAS2e}(KW(R~u z!-^LB#`1mZTlI>XN-7(YZMYH02wFxC5eZporwDxrOfImsqCQ-jOoc~46cpcN>l6{@ zUqq?JFf)tY4PX0aIKd?oeKud z!#g7_$x$<0-2an&yw9!l`2^lz7^8Gp6!iONsLA)wvC!|3SCn#KE$xW7G4j6+bZ8e0 z9=J2fokI+jjN91pF`pV`f1$@_>{R~b(J~&ompP9-gp=3{b!|9Fh)fnN0kFt@hGF#yx4%iHEod3=69&o z0^=iU=45~F3AZa|bvqptzj=&HBW5$)6`4oxKL|-B|F&r%jW`Q1v0hRhWqib3ga{7W zf=qeVbsJ>s54BtXYuf51(1mR>4zoXAiShsF*XNW<fTe!h{!*(t$c;3nwO#s^LRNco0|O1Z6_rQsn18w z>PLW2$eyPb>8W;jJJRkgVf*E%h#*C;_XhK!zwgC+)@x^%!asxTU%5b|u* zS-N@!ej{LqTI$J{x8I{&JU5)3L=k;XuSQ>0Z{K68jgzOz$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*>E~7knk|9?PueB8RuHIpQ-~mkb?JVVXx%3itjuz zoAR3Z;^D2OzT_I?dtHd(qVq&n0}ql{&7@ONA|9?XWIdqY9(*LbeZcDzM&cFh5K2e+wB~@2u z-KaB~&fx-4@4tN;?vjz!5K?9;f5dP}uMhm#e;v zoDp^7XJj$W6j6;zI$74?_$oXXna#~FkUXh?@eAkg?X^Bi!`OC3lV7?K8C-=tM09By zFjeWw^Gvr1l+iXXkkwtG|&3?}k1Ifa=ZxWAxk|?r1Ai(*2YdIHN## z^@;w|^>~7 z=;`|A>7T$ywi-49W*&{?*)Vvp^ZH2 z^nge+BQhA5nNaoq1=L6&I=oZr%Bmpe%V(%d$>aNST;IRY?-UnHDu6Qtay!EP-6aQ> zIfc@rw5tQ}AbcwaF=Rw0AfFHc{kuCY{%h1kli z4U|j%HQ9OfFEC;o>lEVTS6IpaZMgqkbuz|609@lkg8J*axzmpw0NmgPtX|JG;lBW? CQ_YnC diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1baf1f..ac756a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,18 @@ name: ci on: + schedule: + - cron: '0 10 * * *' # everyday at 10am push: branches: - - master - - releases/v* - paths-ignore: - - "**.md" + - 'master' + - 'releases/v*' + tags: + - 'v*' pull_request: branches: - - master - - releases/v* - paths-ignore: - - "**.md" + - 'master' + - 'releases/v*' jobs: main: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54e6851..93790e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,28 +3,14 @@ name: test on: push: branches: - - master - - releases/v* - paths-ignore: - - "**.md" + - 'master' + - 'releases/v*' pull_request: - paths-ignore: - - "**.md" + branches: + - 'master' + - 'releases/v*' jobs: - test-containerized: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Validate - run: docker buildx bake validate - - - name: Test - run: docker buildx bake test - test: runs-on: ubuntu-latest steps: @@ -32,15 +18,17 @@ jobs: name: Checkout uses: actions/checkout@v2 - - name: Install - run: yarn install + name: Validate + uses: docker/bake-action@v1 + with: + targets: validate - name: Test - run: yarn run test + uses: docker/bake-action@v1 + with: + targets: test - name: Upload coverage uses: codecov/codecov-action@v1 - if: success() with: - token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage/clover.xml diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index dba2525..0000000 --- a/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -#syntax=docker/dockerfile:1.2 - -FROM node:14 AS deps -WORKDIR /src -COPY package.json yarn.lock ./ -RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \ - yarn install - -FROM scratch AS update-yarn -COPY --from=deps /src/yarn.lock / - -FROM deps AS validate-yarn -COPY .git .git -RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi - -FROM deps AS base -COPY . . - -FROM base AS build -RUN yarn build - -FROM deps AS test -COPY --from=docker /usr/local/bin/docker /usr/bin/ -ARG TARGETOS -ARG TARGETARCH -ARG BUILDX_VERSION=v0.4.2 -ENV RUNNER_TEMP=/tmp/github_runner -ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache -RUN mkdir -p /usr/local/lib/docker/cli-plugins && \ - curl -fsSL https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.$TARGETOS-$TARGETARCH > /usr/local/lib/docker/cli-plugins/docker-buildx && \ - chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx && \ - docker buildx version -COPY . . -RUN yarn run test - -FROM base AS run-format -RUN yarn run format - -FROM scratch AS format -COPY --from=run-format /src/src/*.ts /src/ - -FROM base AS validate-format -RUN yarn run format-check - -FROM scratch AS dist -COPY --from=build /src/dist/ /dist/ - -FROM build AS validate-build -RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi - -FROM base AS dev -ENTRYPOINT ["bash"] diff --git a/dist/index.js b/dist/index.js index 8263f37..e50e40c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -528,17 +528,17 @@ function run() { const inputs = yield context.getInputs(); const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); if (!(yield buildx.isAvailable()) || inputs.version) { - core.startGroup(`👉 Installing Buildx`); + core.startGroup(`Installing buildx`); yield buildx.install(inputs.version || 'latest', dockerConfigHome); core.endGroup(); } const buildxVersion = yield buildx.getVersion(); - core.info(`📣 Buildx version: ${buildxVersion}`); + core.info(`Using buildx ${buildxVersion}`); const builderName = inputs.driver == 'docker' ? 'default' : `builder-${__webpack_require__(840).v4()}`; core.setOutput('name', builderName); stateHelper.setBuilderName(builderName); if (inputs.driver !== 'docker') { - core.startGroup(`🔨 Creating a new builder instance`); + core.startGroup(`Creating a new builder instance`); let createArgs = ['buildx', 'create', '--name', builderName, '--driver', inputs.driver]; if (semver.satisfies(buildxVersion, '>=0.3.0')) { yield context.asyncForEach(inputs.driverOpts, (driverOpt) => __awaiter(this, void 0, void 0, function* () { @@ -556,7 +556,7 @@ function run() { } yield exec.exec('docker', createArgs); core.endGroup(); - core.startGroup(`🏃 Booting builder`); + core.startGroup(`Booting builder`); let bootstrapArgs = ['buildx', 'inspect', '--bootstrap']; if (semver.satisfies(buildxVersion, '>=0.4.0')) { bootstrapArgs.push('--builder', builderName); @@ -565,11 +565,11 @@ function run() { core.endGroup(); } if (inputs.install) { - core.startGroup(`🤝 Setting buildx as default builder`); + core.startGroup(`Setting buildx as default builder`); yield exec.exec('docker', ['buildx', 'install']); core.endGroup(); } - core.startGroup(`🛒 Extracting available platforms`); + core.startGroup(`Extracting available platforms`); const platforms = yield buildx.platforms(); core.info(`${platforms}`); core.setOutput('platforms', platforms); @@ -2185,7 +2185,7 @@ function install(inputVersion, dockerConfigHome) { if (!release) { throw new Error(`Cannot find buildx ${inputVersion} release`); } - core.debug(`Release found: ${release.tag_name}`); + core.debug(`Release ${release.tag_name} found`); const version = release.tag_name.replace(/^v+|v+$/g, ''); let toolPath; toolPath = tc.find('buildx', version); @@ -2205,7 +2205,7 @@ function install(inputVersion, dockerConfigHome) { const pluginPath = path.join(pluginsDir, filename); core.debug(`Plugin path is ${pluginPath}`); fs.copyFileSync(path.join(toolPath, filename), pluginPath); - core.info('🔨 Fixing perms...'); + core.info('Fixing perms'); fs.chmodSync(pluginPath, '0755'); return pluginPath; }); @@ -2217,7 +2217,7 @@ function download(version) { const downloadUrl = util.format('https://github.com/docker/buildx/releases/download/v%s/%s', version, yield filename(version)); let downloadPath; try { - core.info(`⬇️ Downloading ${downloadUrl}...`); + core.info(`Downloading ${downloadUrl}`); downloadPath = yield tc.downloadTool(downloadUrl); core.debug(`Downloaded to ${downloadPath}`); } diff --git a/docker-bake.hcl b/docker-bake.hcl index f7f1745..7054cf7 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,42 +1,67 @@ +variable "NODE_VERSION" { + default = "12" +} + +target "node-version" { + args = { + NODE_VERSION = NODE_VERSION + } +} + group "default" { targets = ["build"] } group "pre-checkin" { - targets = ["update-yarn", "format", "build"] + targets = ["vendor-update", "format", "build"] } group "validate" { - targets = ["validate-format", "validate-build", "validate-yarn"] -} - -target "update-yarn" { - target = "update-yarn" - output = ["."] + targets = ["format-validate", "build-validate", "vendor-validate"] } target "build" { - target = "dist" + inherits = ["node-version"] + dockerfile = "./hack/build.Dockerfile" + target = "build-update" output = ["."] } -target "test" { - target = "test" +target "build-validate" { + inherits = ["node-version"] + dockerfile = "./hack/build.Dockerfile" + target = "build-validate" } target "format" { - target = "format" + inherits = ["node-version"] + dockerfile = "./hack/build.Dockerfile" + target = "format-update" output = ["."] } -target "validate-format" { - target = "validate-format" +target "format-validate" { + inherits = ["node-version"] + dockerfile = "./hack/build.Dockerfile" + target = "format-validate" +} + +target "vendor-update" { + inherits = ["node-version"] + dockerfile = "./hack/vendor.Dockerfile" + target = "update" + output = ["."] } -target "validate-build" { - target = "validate-build" +target "vendor-validate" { + inherits = ["node-version"] + dockerfile = "./hack/vendor.Dockerfile" + target = "validate" } -target "validate-yarn" { - target = "validate-yarn" -} \ No newline at end of file +target "test" { + inherits = ["node-version"] + dockerfile = "./hack/test.Dockerfile" + target = "test-coverage" + output = ["./coverage"] +} diff --git a/hack/build.Dockerfile b/hack/build.Dockerfile new file mode 100644 index 0000000..a0796d7 --- /dev/null +++ b/hack/build.Dockerfile @@ -0,0 +1,42 @@ +# syntax=docker/dockerfile:1.2 +ARG NODE_VERSION + +FROM node:${NODE_VERSION}-alpine AS base +RUN apk add --no-cache cpio findutils git +WORKDIR /src + +FROM base AS deps +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + yarn install + +FROM deps AS build +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + yarn run build && mkdir /out && cp -Rf dist /out/ + +FROM scratch AS build-update +COPY --from=build /out / + +FROM build AS build-validate +RUN --mount=type=bind,target=.,rw \ + git add -A && cp -rf /out/* .; \ + if [ -n "$(git status --porcelain -- dist)" ]; then \ + echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \ + git status --porcelain -- dist; \ + exit 1; \ + fi + +FROM deps AS format +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + yarn run format \ + && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out + +FROM scratch AS format-update +COPY --from=format /out / + +FROM deps AS format-validate +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + yarn run format-check \ diff --git a/hack/shell b/hack/shell deleted file mode 100755 index 97b23ea..0000000 --- a/hack/shell +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX) -DOCKER_BUILDKIT=1 docker build --iidfile $iidfile --progress=plain . -docker run -it --rm $(cat $iidfile) -docker rmi $(cat $iidfile) diff --git a/hack/test.Dockerfile b/hack/test.Dockerfile new file mode 100644 index 0000000..6a6c5d6 --- /dev/null +++ b/hack/test.Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1.2 +ARG NODE_VERSION + +FROM node:${NODE_VERSION}-alpine AS base +RUN apk add --no-cache git +WORKDIR /src + +FROM base AS deps +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + yarn install + +FROM deps AS test +ENV RUNNER_TEMP=/tmp/github_runner +ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + --mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \ + --mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \ + yarn run test --coverageDirectory=/tmp/coverage + +FROM scratch AS test-coverage +COPY --from=test /tmp/coverage / diff --git a/hack/vendor.Dockerfile b/hack/vendor.Dockerfile new file mode 100644 index 0000000..dd7906b --- /dev/null +++ b/hack/vendor.Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1.2 +ARG NODE_VERSION + +FROM node:${NODE_VERSION}-alpine AS base +RUN apk add --no-cache git +WORKDIR /src + +FROM base AS vendored +RUN --mount=type=bind,target=.,rw \ + --mount=type=cache,target=/src/node_modules \ + yarn install && mkdir /out && cp yarn.lock /out + +FROM scratch AS update +COPY --from=vendored /out / + +FROM vendored AS validate +RUN --mount=type=bind,target=.,rw \ + git add -A && cp -rf /out/* .; \ + if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \ + echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ + git status --porcelain -- yarn.lock; \ + exit 1; \ + fi diff --git a/src/buildx.ts b/src/buildx.ts index 912cbf0..e1ee9f3 100644 --- a/src/buildx.ts +++ b/src/buildx.ts @@ -52,7 +52,7 @@ export async function install(inputVersion: string, dockerConfigHome: string): P if (!release) { throw new Error(`Cannot find buildx ${inputVersion} release`); } - core.debug(`Release found: ${release.tag_name}`); + core.debug(`Release ${release.tag_name} found`); const version = release.tag_name.replace(/^v+|v+$/g, ''); let toolPath: string; @@ -76,7 +76,7 @@ export async function install(inputVersion: string, dockerConfigHome: string): P core.debug(`Plugin path is ${pluginPath}`); fs.copyFileSync(path.join(toolPath, filename), pluginPath); - core.info('🔨 Fixing perms...'); + core.info('Fixing perms'); fs.chmodSync(pluginPath, '0755'); return pluginPath; @@ -92,7 +92,7 @@ async function download(version: string): Promise { let downloadPath: string; try { - core.info(`⬇️ Downloading ${downloadUrl}...`); + core.info(`Downloading ${downloadUrl}`); downloadPath = await tc.downloadTool(downloadUrl); core.debug(`Downloaded to ${downloadPath}`); } catch (error) { diff --git a/src/main.ts b/src/main.ts index d5eb526..560524c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,20 +19,20 @@ async function run(): Promise { const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); if (!(await buildx.isAvailable()) || inputs.version) { - core.startGroup(`👉 Installing Buildx`); + core.startGroup(`Installing buildx`); await buildx.install(inputs.version || 'latest', dockerConfigHome); core.endGroup(); } const buildxVersion = await buildx.getVersion(); - core.info(`📣 Buildx version: ${buildxVersion}`); + core.info(`Using buildx ${buildxVersion}`); const builderName: string = inputs.driver == 'docker' ? 'default' : `builder-${require('uuid').v4()}`; core.setOutput('name', builderName); stateHelper.setBuilderName(builderName); if (inputs.driver !== 'docker') { - core.startGroup(`🔨 Creating a new builder instance`); + core.startGroup(`Creating a new builder instance`); let createArgs: Array = ['buildx', 'create', '--name', builderName, '--driver', inputs.driver]; if (semver.satisfies(buildxVersion, '>=0.3.0')) { await context.asyncForEach(inputs.driverOpts, async driverOpt => { @@ -51,7 +51,7 @@ async function run(): Promise { await exec.exec('docker', createArgs); core.endGroup(); - core.startGroup(`🏃 Booting builder`); + core.startGroup(`Booting builder`); let bootstrapArgs: Array = ['buildx', 'inspect', '--bootstrap']; if (semver.satisfies(buildxVersion, '>=0.4.0')) { bootstrapArgs.push('--builder', builderName); @@ -61,12 +61,12 @@ async function run(): Promise { } if (inputs.install) { - core.startGroup(`🤝 Setting buildx as default builder`); + core.startGroup(`Setting buildx as default builder`); await exec.exec('docker', ['buildx', 'install']); core.endGroup(); } - core.startGroup(`🛒 Extracting available platforms`); + core.startGroup(`Extracting available platforms`); const platforms = await buildx.platforms(); core.info(`${platforms}`); core.setOutput('platforms', platforms);