Skip to content

Commit

Permalink
Fix and cleanup of v2 setup actions
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
CrazyMax committed Aug 16, 2020
1 parent 3f08c86 commit e9cb922
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 3,855 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/setup-buildx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ jobs:
- v0.2.2
- ""
steps:
-
name: Runner info
run: |
sudo apt-get install -y hwinfo
sudo hwinfo --short
sudo mount
-
name: Checkout
uses: actions/checkout@v2.3.1
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/setup-buildx-precheckin.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .github/workflows/setup-qemu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ jobs:
- all
- arm64,riscv64,arm
steps:
-
name: Runner info
run: |
sudo apt-get install -y hwinfo
sudo hwinfo --short
sudo mount
-
name: Checkout
uses: actions/checkout@v2.3.1
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/setup-qemu-precheckin.yml

This file was deleted.

6 changes: 3 additions & 3 deletions setup-buildx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
-
name: Set up Docker Buildx
id: buildx
uses: docker/actions/setup-buildx@v1
uses: docker/setup-buildx-action@v1
with:
version: latest
-
Expand Down Expand Up @@ -71,13 +71,13 @@ jobs:
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/actions/setup-qemu@v1
uses: docker/setup-qemu-action@v1
with:
platforms: all
-
name: Set up Docker Buildx
id: buildx
uses: docker/actions/setup-buildx@v1
uses: docker/setup-buildx-action@v1
with:
version: latest
-
Expand Down
8 changes: 4 additions & 4 deletions setup-buildx/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'Docker - Setup Buildx'
description: 'GitHub Action to set up Docker Buildx'
author: 'crazy-max'
name: 'Docker Setup Buildx'
description: 'Set up Docker Buildx'
author: 'docker'
branding:
icon: 'anchor'
color: 'blue'
icon: 'truck'

inputs:
version:
Expand Down
30 changes: 16 additions & 14 deletions setup-buildx/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions setup-buildx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-buildx",
"description": "GitHub Action to set up Docker Buildx",
"description": "Set up Docker Buildx",
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build",
Expand All @@ -11,15 +11,17 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/docker/actions.git",
"directory": "setup-buildx"
"url": "git+https://github.com/docker/setup-buildx-action.git"
},
"keywords": [
"actions",
"docker",
"buildx"
],
"author": "CrazyMax",
"author": "Docker",
"contributors": [
"CrazyMax"
],
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.2.4",
Expand All @@ -32,7 +34,6 @@
"@types/jest": "^26.0.3",
"@types/node": "^14.0.14",
"@zeit/ncc": "^0.22.3",
"dotenv": "^8.2.0",
"jest": "^26.1.0",
"jest-circus": "^26.1.0",
"jest-runtime": "^26.1.0",
Expand Down
4 changes: 2 additions & 2 deletions setup-buildx/src/exec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actionsExec from '@actions/exec';
import * as aexec from '@actions/exec';
import {ExecOptions} from '@actions/exec';

export interface ExecResult {
Expand All @@ -24,7 +24,7 @@ export const exec = async (command: string, args: string[] = [], silent: boolean
}
};

const returnCode: number = await actionsExec.exec(command, args, options);
const returnCode: number = await aexec.exec(command, args, options);

return {
success: returnCode === 0,
Expand Down
23 changes: 13 additions & 10 deletions setup-buildx/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as os from 'os';
import * as path from 'path';
import * as buildx from './buildx';
import * as exec from './exec';
import * as mexec from './exec';
import * as stateHelper from './state-helper';
import * as core from '@actions/core';
import * as exec from '@actions/exec';

async function run(): Promise<void> {
try {
Expand All @@ -25,7 +26,7 @@ async function run(): Promise<void> {
}

core.info('📣 Buildx info');
await exec.exec('docker', ['buildx', 'version'], false);
await exec.exec('docker', ['buildx', 'version']);

const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
core.setOutput('name', builderName);
Expand All @@ -40,14 +41,14 @@ async function run(): Promise<void> {
createArgs.push('--use');
}

await exec.exec('docker', createArgs, false);
await exec.exec('docker', createArgs);

core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false);
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);

if (bxInstall) {
core.info('🤝 Setting buildx as default builder...');
await exec.exec('docker', ['buildx', 'install'], false);
await exec.exec('docker', ['buildx', 'install']);
}

core.info('🛒 Extracting available platforms...');
Expand All @@ -60,12 +61,14 @@ async function run(): Promise<void> {
}

async function cleanup(): Promise<void> {
try {
core.info('🚿 Removing builder instance...');
await exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false);
} catch (error) {
core.warning(error.message);
if (stateHelper.builderName.length == 0) {
return;
}
await mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
if (res.stderr != '' && !res.success) {
core.warning(res.stderr);
}
});
}

if (!stateHelper.IsPost) {
Expand Down
2 changes: 1 addition & 1 deletion setup-buildx/src/state-helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core';

export const IsPost = !!process.env['STATE_isPost'];
export const builderName = !!process.env['STATE_builderName'];
export const builderName = process.env['STATE_builderName'] || '';

export function setBuilderName(builderName: string) {
core.saveState('builderName', builderName);
Expand Down
5 changes: 0 additions & 5 deletions setup-buildx/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1236,11 +1236,6 @@ domexception@^2.0.1:
dependencies:
webidl-conversions "^5.0.0"

dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==

ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"
Expand Down
2 changes: 1 addition & 1 deletion setup-qemu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
-
name: Set up QEMU
id: qemu
uses: docker/actions/setup-qemu@v1
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
Expand Down
8 changes: 4 additions & 4 deletions setup-qemu/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'Docker - Setup QEMU'
description: 'GitHub Action to install QEMU static binaries'
author: 'crazy-max'
name: 'Docker Setup QEMU'
description: 'Install QEMU static binaries'
author: 'docker'
branding:
icon: 'anchor'
color: 'blue'
icon: 'truck'

inputs:
image:
Expand Down
Loading

0 comments on commit e9cb922

Please sign in to comment.