From 6e98909587fb44bd67b3c107108b01e1b75388dc Mon Sep 17 00:00:00 2001 From: iLTeoooD Date: Mon, 6 Jan 2020 12:45:44 +0100 Subject: [PATCH] First commit! --- README.md | 15 ++ action.yml | 22 ++ index.js | 57 +++++ node_modules/@actions/core/README.md | 140 +++++++++++++ node_modules/@actions/core/lib/command.d.ts | 16 ++ node_modules/@actions/core/lib/command.js | 66 ++++++ node_modules/@actions/core/lib/command.js.map | 1 + node_modules/@actions/core/lib/core.d.ts | 112 ++++++++++ node_modules/@actions/core/lib/core.js | 195 ++++++++++++++++++ node_modules/@actions/core/lib/core.js.map | 1 + node_modules/@actions/core/package.json | 64 ++++++ package-lock.json | 13 ++ package.json | 15 ++ scripts/docker_build.sh | 2 + scripts/docker_build_push.sh | 2 + scripts/dockerhub_login.sh | 3 + scripts/install_buildx.sh | 28 +++ 17 files changed, 752 insertions(+) create mode 100644 README.md create mode 100644 action.yml create mode 100644 index.js create mode 100644 node_modules/@actions/core/README.md create mode 100644 node_modules/@actions/core/lib/command.d.ts create mode 100644 node_modules/@actions/core/lib/command.js create mode 100644 node_modules/@actions/core/lib/command.js.map create mode 100644 node_modules/@actions/core/lib/core.d.ts create mode 100644 node_modules/@actions/core/lib/core.js create mode 100644 node_modules/@actions/core/lib/core.js.map create mode 100644 node_modules/@actions/core/package.json create mode 100644 package-lock.json create mode 100644 package.json create mode 100755 scripts/docker_build.sh create mode 100755 scripts/docker_build_push.sh create mode 100755 scripts/dockerhub_login.sh create mode 100755 scripts/install_buildx.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..080a975 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# docker_buildx + +GitHub Action to build and publish images using [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/). + +## Inputs +The accepted inputs are: + +| Name | Type | Default | Mandatory | Description | +|---------------|-----------|-----------|-------------|-----------------------------------------------------------------| +| `tag` | String | `latest` | No | Tag to apply to the image | +| `imageName` | String | | Yes | Name of the image | +| `publish` | Boolean | `false` | No | Indicate if the builded image should be published on Docker HUB | +| `platform` | String | `linux/amd64,linux/arm64,linux/arm/v7` | No | Platforms (*comma separated*) that should be used to build the image | | +| `dockerHubUser` | String | | Only if `publish` is true | User that will publish the image | +| `dockerHubPassword` | String | | Only if `publish` is true | Password of the `dockerHubUser` | \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..ea8b646 --- /dev/null +++ b/action.yml @@ -0,0 +1,22 @@ +name: "Docker buildx" +description: "Configure docker to be used with buildx" +inputs: + tag: + description: "Tag to apply to the image" + default: "latest" + imageName: + description: "Name of the image" + required: true + publish: + description: "Indicate if the builded image should be published on Docker HUB" + default: "false" + platform: + description: "Platforms (comma separated) that should be used to build the image" + default: "linux/amd64,linux/arm64,linux/arm/v7" + dockerHubUser: + description: "User that will publish the image, if indicated" + dockerHubPassword: + description: "Password of the dockerHubUser" +runs: + using: 'node12' + main: index.js \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..3418858 --- /dev/null +++ b/index.js @@ -0,0 +1,57 @@ +const core = require('@actions/core'); +const os = require('os'); +const child_process = require('child_process'); + +async function docker_buildx() { + try { + checkPlatform(); + const imageName = extractInput('imageName', true); + await executeShellScript('install_buildx'); + const imageTag = extractInput('tag', false, 'latest'); + const publish = core.getInput('publish'); + const platform = extractInput('platform', false, 'linux/amd64,linux/arm64,linux/arm/v7'); + const buildFunction = publish ? buildAndPublish : buildOnly; + buildFunction(platform, imageName, imageTag); + } catch (error) { + core.setFailed(error.message); + } +} + +function checkPlatform() { + if (os.platform() !== 'linux') { + throw new Error('Only supported on linux platform') + } +} + +function extractInput(inputName, required, defaultValue) { + const inputValue = core.getInput(inputName); + if(required) checkRequiredInput(inputName, inputValue); + return inputValue ? inputValue : defaultValue; +} + +function checkRequiredInput(inputName, inputValue) { + if (!inputValue) { + throw new Error(`The parameter ${inputName} is missing`); + } +} + +async function executeShellScript(scriptName, ...parameters) { + parameters = (parameters || []).join(' '); + command = `./scripts/${scriptName}.sh ${parameters}`; + console.log(`Executing: ${command}`); + output = child_process.execSync(`./scripts/${scriptName}.sh ${parameters}`); + console.log(`Output: ${output}`); +} + +async function buildAndPublish(platform, imageName, imageTag) { + const dockerHubUser = extractInput('dockerHubUser', true); + const dockerHubPassword = extractInput('dockerHubPassword', true); + await executeShellScript('dockerhub_login', dockerHubUser, dockerHubPassword); + await executeShellScript('docker_build_push', platform, imageName, imageTag); +} + +async function buildOnly(platform, imageName, imageTag) { + await executeShellScript('docker_build', platform, imageName, imageTag); +} + +docker_buildx(); \ No newline at end of file diff --git a/node_modules/@actions/core/README.md b/node_modules/@actions/core/README.md new file mode 100644 index 0000000..457f73c --- /dev/null +++ b/node_modules/@actions/core/README.md @@ -0,0 +1,140 @@ +# `@actions/core` + +> Core functions for setting results, logging, registering secrets and exporting variables across actions + +## Usage + +### Import the package + +```js +// javascript +const core = require('@actions/core'); + +// typescript +import * as core from '@actions/core'; +``` + +#### Inputs/Outputs + +Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled. + +```js +const myInput = core.getInput('inputName', { required: true }); + +core.setOutput('outputKey', 'outputVal'); +``` + +#### Exporting variables + +Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks. + +```js +core.exportVariable('envVar', 'Val'); +``` + +#### Setting a secret + +Setting a secret registers the secret with the runner to ensure it is masked in logs. + +```js +core.setSecret('myPassword'); +``` + +#### PATH Manipulation + +To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`. The runner will prepend the path given to the jobs PATH. + +```js +core.addPath('/path/to/mytool'); +``` + +#### Exit codes + +You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success. + +```js +const core = require('@actions/core'); + +try { + // Do stuff +} +catch (err) { + // setFailed logs the message and sets a failing exit code + core.setFailed(`Action failed with error ${err}`); +} + +Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned. + +``` + +#### Logging + +Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs). + +```js +const core = require('@actions/core'); + +const myInput = core.getInput('input'); +try { + core.debug('Inside try block'); + + if (!myInput) { + core.warning('myInput was not set'); + } + + // Do stuff +} +catch (err) { + core.error(`Error ${err}, action may still succeed though`); +} +``` + +This library can also wrap chunks of output in foldable groups. + +```js +const core = require('@actions/core') + +// Manually wrap output +core.startGroup('Do some function') +doSomeFunction() +core.endGroup() + +// Wrap an asynchronous function call +const result = await core.group('Do something async', async () => { + const response = await doSomeHTTPRequest() + return response +}) +``` + +#### Action state + +You can use this library to save state and get state for sharing information between a given wrapper action: + +**action.yml** +```yaml +name: 'Wrapper action sample' +inputs: + name: + default: 'GitHub' +runs: + using: 'node12' + main: 'main.js' + post: 'cleanup.js' +``` + +In action's `main.js`: + +```js +const core = require('@actions/core'); + +core.saveState("pidToKill", 12345); +``` + +In action's `cleanup.js`: +```js +const core = require('@actions/core'); + +var pid = core.getState("pidToKill"); + +process.kill(pid); +``` \ No newline at end of file diff --git a/node_modules/@actions/core/lib/command.d.ts b/node_modules/@actions/core/lib/command.d.ts new file mode 100644 index 0000000..7f6fecb --- /dev/null +++ b/node_modules/@actions/core/lib/command.d.ts @@ -0,0 +1,16 @@ +interface CommandProperties { + [key: string]: string; +} +/** + * Commands + * + * Command Format: + * ##[name key=value;key=value]message + * + * Examples: + * ##[warning]This is the user warning message + * ##[set-secret name=mypassword]definitelyNotAPassword! + */ +export declare function issueCommand(command: string, properties: CommandProperties, message: string): void; +export declare function issue(name: string, message?: string): void; +export {}; diff --git a/node_modules/@actions/core/lib/command.js b/node_modules/@actions/core/lib/command.js new file mode 100644 index 0000000..b0ea009 --- /dev/null +++ b/node_modules/@actions/core/lib/command.js @@ -0,0 +1,66 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const os = require("os"); +/** + * Commands + * + * Command Format: + * ##[name key=value;key=value]message + * + * Examples: + * ##[warning]This is the user warning message + * ##[set-secret name=mypassword]definitelyNotAPassword! + */ +function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message); + process.stdout.write(cmd.toString() + os.EOL); +} +exports.issueCommand = issueCommand; +function issue(name, message = '') { + issueCommand(name, {}, message); +} +exports.issue = issue; +const CMD_STRING = '::'; +class Command { + constructor(command, properties, message) { + if (!command) { + command = 'missing.command'; + } + this.command = command; + this.properties = properties; + this.message = message; + } + toString() { + let cmdStr = CMD_STRING + this.command; + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += ' '; + for (const key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key]; + if (val) { + // safely append the val - avoid blowing up when attempting to + // call .replace() if message is not a string for some reason + cmdStr += `${key}=${escape(`${val || ''}`)},`; + } + } + } + } + cmdStr += CMD_STRING; + // safely append the message - avoid blowing up when attempting to + // call .replace() if message is not a string for some reason + const message = `${this.message || ''}`; + cmdStr += escapeData(message); + return cmdStr; + } +} +function escapeData(s) { + return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); +} +function escape(s) { + return s + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + .replace(/]/g, '%5D') + .replace(/;/g, '%3B'); +} +//# sourceMappingURL=command.js.map \ No newline at end of file diff --git a/node_modules/@actions/core/lib/command.js.map b/node_modules/@actions/core/lib/command.js.map new file mode 100644 index 0000000..918ab25 --- /dev/null +++ b/node_modules/@actions/core/lib/command.js.map @@ -0,0 +1 @@ +{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAA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M,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"} \ No newline at end of file diff --git a/node_modules/@actions/core/lib/core.d.ts b/node_modules/@actions/core/lib/core.d.ts new file mode 100644 index 0000000..6483c3c --- /dev/null +++ b/node_modules/@actions/core/lib/core.d.ts @@ -0,0 +1,112 @@ +/** + * Interface for getInput options + */ +export interface InputOptions { + /** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */ + required?: boolean; +} +/** + * The code to exit an action + */ +export declare enum ExitCode { + /** + * A code indicating that the action was successful + */ + Success = 0, + /** + * A code indicating that the action was a failure + */ + Failure = 1 +} +/** + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable + */ +export declare function exportVariable(name: string, val: string): void; +/** + * Registers a secret which will get masked from logs + * @param secret value of the secret + */ +export declare function setSecret(secret: string): void; +/** + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath + */ +export declare function addPath(inputPath: string): void; +/** + * Gets the value of an input. The value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string + */ +export declare function getInput(name: string, options?: InputOptions): string; +/** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store + */ +export declare function setOutput(name: string, value: string): void; +/** + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message + */ +export declare function setFailed(message: string): void; +/** + * Writes debug message to user log + * @param message debug message + */ +export declare function debug(message: string): void; +/** + * Adds an error issue + * @param message error issue message + */ +export declare function error(message: string): void; +/** + * Adds an warning issue + * @param message warning issue message + */ +export declare function warning(message: string): void; +/** + * Writes info to log with console.log. + * @param message info message + */ +export declare function info(message: string): void; +/** + * Begin an output group. + * + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group + */ +export declare function startGroup(name: string): void; +/** + * End an output group. + */ +export declare function endGroup(): void; +/** + * Wrap an asynchronous function call in a group. + * + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group + */ +export declare function group(name: string, fn: () => Promise): Promise; +/** + * Saves state for current action, the state can only be retrieved by this action's post job execution. + * + * @param name name of the state to store + * @param value value to store + */ +export declare function saveState(name: string, value: string): void; +/** + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string + */ +export declare function getState(name: string): string; diff --git a/node_modules/@actions/core/lib/core.js b/node_modules/@actions/core/lib/core.js new file mode 100644 index 0000000..f43d507 --- /dev/null +++ b/node_modules/@actions/core/lib/core.js @@ -0,0 +1,195 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const command_1 = require("./command"); +const os = require("os"); +const path = require("path"); +/** + * The code to exit an action + */ +var ExitCode; +(function (ExitCode) { + /** + * A code indicating that the action was successful + */ + ExitCode[ExitCode["Success"] = 0] = "Success"; + /** + * A code indicating that the action was a failure + */ + ExitCode[ExitCode["Failure"] = 1] = "Failure"; +})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); +//----------------------------------------------------------------------- +// Variables +//----------------------------------------------------------------------- +/** + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable + */ +function exportVariable(name, val) { + process.env[name] = val; + command_1.issueCommand('set-env', { name }, val); +} +exports.exportVariable = exportVariable; +/** + * Registers a secret which will get masked from logs + * @param secret value of the secret + */ +function setSecret(secret) { + command_1.issueCommand('add-mask', {}, secret); +} +exports.setSecret = setSecret; +/** + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath + */ +function addPath(inputPath) { + command_1.issueCommand('add-path', {}, inputPath); + process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; +} +exports.addPath = addPath; +/** + * Gets the value of an input. The value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string + */ +function getInput(name, options) { + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`); + } + return val.trim(); +} +exports.getInput = getInput; +/** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store + */ +function setOutput(name, value) { + command_1.issueCommand('set-output', { name }, value); +} +exports.setOutput = setOutput; +//----------------------------------------------------------------------- +// Results +//----------------------------------------------------------------------- +/** + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message + */ +function setFailed(message) { + process.exitCode = ExitCode.Failure; + error(message); +} +exports.setFailed = setFailed; +//----------------------------------------------------------------------- +// Logging Commands +//----------------------------------------------------------------------- +/** + * Writes debug message to user log + * @param message debug message + */ +function debug(message) { + command_1.issueCommand('debug', {}, message); +} +exports.debug = debug; +/** + * Adds an error issue + * @param message error issue message + */ +function error(message) { + command_1.issue('error', message); +} +exports.error = error; +/** + * Adds an warning issue + * @param message warning issue message + */ +function warning(message) { + command_1.issue('warning', message); +} +exports.warning = warning; +/** + * Writes info to log with console.log. + * @param message info message + */ +function info(message) { + process.stdout.write(message + os.EOL); +} +exports.info = info; +/** + * Begin an output group. + * + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group + */ +function startGroup(name) { + command_1.issue('group', name); +} +exports.startGroup = startGroup; +/** + * End an output group. + */ +function endGroup() { + command_1.issue('endgroup'); +} +exports.endGroup = endGroup; +/** + * Wrap an asynchronous function call in a group. + * + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group + */ +function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name); + let result; + try { + result = yield fn(); + } + finally { + endGroup(); + } + return result; + }); +} +exports.group = group; +//----------------------------------------------------------------------- +// Wrapper action state +//----------------------------------------------------------------------- +/** + * Saves state for current action, the state can only be retrieved by this action's post job execution. + * + * @param name name of the state to store + * @param value value to store + */ +function saveState(name, value) { + command_1.issueCommand('save-state', { name }, value); +} +exports.saveState = saveState; +/** + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string + */ +function getState(name) { + return process.env[`STATE_${name}`] || ''; +} +exports.getState = getState; +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/node_modules/@actions/core/lib/core.js.map b/node_modules/@actions/core/lib/core.js.map new file mode 100644 index 0000000..6eda8da --- /dev/null +++ b/node_modules/@actions/core/lib/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,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E,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC"} \ No newline at end of file diff --git a/node_modules/@actions/core/package.json b/node_modules/@actions/core/package.json new file mode 100644 index 0000000..dbcfaa1 --- /dev/null +++ b/node_modules/@actions/core/package.json @@ -0,0 +1,64 @@ +{ + "_from": "@actions/core@^1.2.0", + "_id": "@actions/core@1.2.0", + "_inBundle": false, + "_integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==", + "_location": "/@actions/core", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "@actions/core@^1.2.0", + "name": "@actions/core", + "escapedName": "@actions%2fcore", + "scope": "@actions", + "rawSpec": "^1.2.0", + "saveSpec": null, + "fetchSpec": "^1.2.0" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", + "_shasum": "aa5f52b26c362c821d41557e599371a42f6c0b3d", + "_spec": "@actions/core@^1.2.0", + "_where": "/home/teo/Documenti/git/personale/docker_buildx", + "bugs": { + "url": "https://github.com/actions/toolkit/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Actions core lib", + "devDependencies": { + "@types/node": "^12.0.2" + }, + "directories": { + "lib": "lib", + "test": "__tests__" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/actions/toolkit/tree/master/packages/core", + "keywords": [ + "github", + "actions", + "core" + ], + "license": "MIT", + "main": "lib/core.js", + "name": "@actions/core", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/actions/toolkit.git", + "directory": "packages/core" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "tsc": "tsc" + }, + "version": "1.2.0" +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bc3e512 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "docker_buildx", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@actions/core": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", + "integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..023382b --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "docker_buildx", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@actions/core": "^1.2.0" + } +} diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh new file mode 100755 index 0000000..1ee89ad --- /dev/null +++ b/scripts/docker_build.sh @@ -0,0 +1,2 @@ +#!/bin/sh -l +docker buildx build --platform $1 -t $2:$3 . \ No newline at end of file diff --git a/scripts/docker_build_push.sh b/scripts/docker_build_push.sh new file mode 100755 index 0000000..a18e482 --- /dev/null +++ b/scripts/docker_build_push.sh @@ -0,0 +1,2 @@ +#!/bin/sh -l +docker buildx build --platform $1 --push -t $2:$3 . \ No newline at end of file diff --git a/scripts/dockerhub_login.sh b/scripts/dockerhub_login.sh new file mode 100755 index 0000000..a08c288 --- /dev/null +++ b/scripts/dockerhub_login.sh @@ -0,0 +1,3 @@ +#!/bin/sh -l + +docker login -u $1 -p $2 \ No newline at end of file diff --git a/scripts/install_buildx.sh b/scripts/install_buildx.sh new file mode 100755 index 0000000..4cc1293 --- /dev/null +++ b/scripts/install_buildx.sh @@ -0,0 +1,28 @@ +#!/bin/sh -l + +# Install curl +apt-get update +apt-get install curl wget -y + +# Download buildx +curl -s https://api.github.com/repos/docker/buildx/releases/latest \ +| grep "browser_download_url.*buildx-*.*linux-amd64" \ +| cut -d : -f 2,3 \ +| tr -d \" \ +| wget -qi - + +# Confiure buildx +export DOCKER_CLI_EXPERIMENTAL=enabled +mkdir -p ~/.docker/cli-plugins +mv buildx* ~/.docker/cli-plugins/docker-buildx +chmod a+x ~/.docker/cli-plugins/docker-buildx + +# Register Arm executables +docker run --rm --privileged docker/binfmt:820fdd95a9972a5308930a2bdfb8573dd4447ad3 +# Register Multiarch executables +docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + +# Create builder instance +docker buildx create --name actions_builder --use +SUPPORTED_PLATFORMS=$(docker buildx inspect --bootstrap | grep 'Platforms:*.*' | cut -d : -f2,3) +echo "Supported platforms: $SUPPORTED_PLATFORMS" \ No newline at end of file