Merge pull request #349 from crazy-max/remove-os-limitation

Remove os limitation
This commit is contained in:
CrazyMax 2021-04-27 16:19:03 +02:00 committed by GitHub
commit 3ce082ae8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -207,6 +207,37 @@ jobs:
uses: crazy-max/ghaction-dump-context@v1 uses: crazy-max/ghaction-dump-context@v1
error: error:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Stop docker
run: |
sudo systemctl stop docker
-
name: Build
id: docker_build
continue-on-error: true
uses: ./
with:
context: ./test
file: ./test/Dockerfile
-
name: Check
run: |
echo "${{ toJson(steps.docker_build) }}"
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
echo "::error::Should have failed"
exit 1
fi
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
error-buildx:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- -

View File

@ -43,7 +43,6 @@ ___
* [outputs](#outputs) * [outputs](#outputs)
* [Troubleshooting](#troubleshooting) * [Troubleshooting](#troubleshooting)
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot) * [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
* [Limitation](#limitation)
## Usage ## Usage
@ -243,7 +242,3 @@ updates:
schedule: schedule:
interval: "daily" interval: "daily"
``` ```
## Limitation
This action is only available for Linux [virtual environments](https://help.github.com/en/articles/virtual-environments-for-github-actions#supported-virtual-environments-and-hardware-resources).

View File

@ -1,6 +1,8 @@
# Troubleshooting # Troubleshooting
* [Cannot push to a registry](#cannot-push-to-a-registry) * [Cannot push to a registry](#cannot-push-to-a-registry)
* [BuildKit container logs](#buildkit-container-logs)
* [With containerd](#with-containerd)
## Cannot push to a registry ## Cannot push to a registry
@ -16,9 +18,13 @@ These issues are not directly related to this action but are rather linked to [b
[buildkit](https://github.com/moby/buildkit), [containerd](https://github.com/containerd/containerd) or the registry [buildkit](https://github.com/moby/buildkit), [containerd](https://github.com/containerd/containerd) or the registry
on which you're pushing your image. The quality of error message depends on the registry and are usually not very informative. on which you're pushing your image. The quality of error message depends on the registry and are usually not very informative.
### BuildKit container logs
To help you solve this, you have to [enable debugging in the setup-buildx](https://github.com/docker/setup-buildx-action#buildkit-container-logs) To help you solve this, you have to [enable debugging in the setup-buildx](https://github.com/docker/setup-buildx-action#buildkit-container-logs)
action step and attach BuildKit container logs to your issue. action step and attach BuildKit container logs to your issue.
### With containerd
Next you can test pushing with [containerd action](https://github.com/crazy-max/ghaction-setup-containerd) using the Next you can test pushing with [containerd action](https://github.com/crazy-max/ghaction-setup-containerd) using the
following workflow. If it works then open an issue on [buildkit](https://github.com/moby/buildkit) repository. following workflow. If it works then open an issue on [buildkit](https://github.com/moby/buildkit) repository.

23
dist/index.js generated vendored
View File

@ -2387,7 +2387,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const buildx = __importStar(__webpack_require__(295)); const buildx = __importStar(__webpack_require__(295));
const context = __importStar(__webpack_require__(842)); const context = __importStar(__webpack_require__(842));
const exec = __importStar(__webpack_require__(757)); const exec = __importStar(__webpack_require__(757));
@ -2396,18 +2395,20 @@ const core = __importStar(__webpack_require__(186));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
if (os.platform() !== 'linux') { core.startGroup(`Docker info`);
throw new Error(`Only supported on linux platform`); yield exec.exec('docker', ['version']);
} yield exec.exec('docker', ['info']);
core.endGroup();
if (!(yield buildx.isAvailable())) { if (!(yield buildx.isAvailable())) {
throw new Error(`Buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`); core.setFailed(`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
return;
} }
stateHelper.setTmpDir(context.tmpDir()); stateHelper.setTmpDir(context.tmpDir());
const buildxVersion = yield buildx.getVersion(); const buildxVersion = yield buildx.getVersion();
core.info(`📣 Buildx version: ${buildxVersion}`); core.info(`Using buildx ${buildxVersion}`);
const defContext = context.defaultContext(); const defContext = context.defaultContext();
let inputs = yield context.getInputs(defContext); let inputs = yield context.getInputs(defContext);
core.info(`🏃 Starting build...`); core.info(`Building...`);
const args = yield context.getArgs(inputs, defContext, buildxVersion); const args = yield context.getArgs(inputs, defContext, buildxVersion);
yield exec.exec('docker', args).then(res => { yield exec.exec('docker', args).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
@ -2416,9 +2417,10 @@ function run() {
}); });
const imageID = yield buildx.getImageID(); const imageID = yield buildx.getImageID();
if (imageID) { if (imageID) {
core.info('🛒 Extracting digest...'); core.startGroup(`Extracting digest`);
core.info(`${imageID}`); core.info(`${imageID}`);
core.setOutput('digest', imageID); core.setOutput('digest', imageID);
core.endGroup();
} }
} }
catch (error) { catch (error) {
@ -2429,8 +2431,9 @@ function run() {
function cleanup() { function cleanup() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (stateHelper.tmpDir.length > 0) { if (stateHelper.tmpDir.length > 0) {
core.info(`🚿 Removing temp folder ${stateHelper.tmpDir}`); core.startGroup(`Removing temp folder ${stateHelper.tmpDir}`);
fs.rmdirSync(stateHelper.tmpDir, { recursive: true }); fs.rmdirSync(stateHelper.tmpDir, { recursive: true });
core.endGroup();
} }
}); });
} }
@ -4695,7 +4698,7 @@ function parseVersion(stdout) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const matches = /\sv?([0-9.]+)/.exec(stdout); const matches = /\sv?([0-9.]+)/.exec(stdout);
if (!matches) { if (!matches) {
throw new Error(`Cannot parse Buildx version`); throw new Error(`Cannot parse buildx version`);
} }
return semver.clean(matches[1]); return semver.clean(matches[1]);
}); });

View File

@ -100,7 +100,7 @@ export async function getVersion(): Promise<string> {
export async function parseVersion(stdout: string): Promise<string> { export async function parseVersion(stdout: string): Promise<string> {
const matches = /\sv?([0-9.]+)/.exec(stdout); const matches = /\sv?([0-9.]+)/.exec(stdout);
if (!matches) { if (!matches) {
throw new Error(`Cannot parse Buildx version`); throw new Error(`Cannot parse buildx version`);
} }
return semver.clean(matches[1]); return semver.clean(matches[1]);
} }

View File

@ -1,5 +1,4 @@
import * as fs from 'fs'; import * as fs from 'fs';
import * as os from 'os';
import * as buildx from './buildx'; import * as buildx from './buildx';
import * as context from './context'; import * as context from './context';
import * as exec from './exec'; import * as exec from './exec';
@ -8,22 +7,24 @@ import * as core from '@actions/core';
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
if (os.platform() !== 'linux') { core.startGroup(`Docker info`);
throw new Error(`Only supported on linux platform`); await exec.exec('docker', ['version']);
} await exec.exec('docker', ['info']);
core.endGroup();
if (!(await buildx.isAvailable())) { if (!(await buildx.isAvailable())) {
throw new Error(`Buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`); core.setFailed(`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
return;
} }
stateHelper.setTmpDir(context.tmpDir()); stateHelper.setTmpDir(context.tmpDir());
const buildxVersion = await buildx.getVersion(); const buildxVersion = await buildx.getVersion();
core.info(`📣 Buildx version: ${buildxVersion}`); core.info(`Using buildx ${buildxVersion}`);
const defContext = context.defaultContext(); const defContext = context.defaultContext();
let inputs: context.Inputs = await context.getInputs(defContext); let inputs: context.Inputs = await context.getInputs(defContext);
core.info(`🏃 Starting build...`); core.info(`Building...`);
const args: string[] = await context.getArgs(inputs, defContext, buildxVersion); const args: string[] = await context.getArgs(inputs, defContext, buildxVersion);
await exec.exec('docker', args).then(res => { await exec.exec('docker', args).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
@ -33,9 +34,10 @@ async function run(): Promise<void> {
const imageID = await buildx.getImageID(); const imageID = await buildx.getImageID();
if (imageID) { if (imageID) {
core.info('🛒 Extracting digest...'); core.startGroup(`Extracting digest`);
core.info(`${imageID}`); core.info(`${imageID}`);
core.setOutput('digest', imageID); core.setOutput('digest', imageID);
core.endGroup();
} }
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@ -44,8 +46,9 @@ async function run(): Promise<void> {
async function cleanup(): Promise<void> { async function cleanup(): Promise<void> {
if (stateHelper.tmpDir.length > 0) { if (stateHelper.tmpDir.length > 0) {
core.info(`🚿 Removing temp folder ${stateHelper.tmpDir}`); core.startGroup(`Removing temp folder ${stateHelper.tmpDir}`);
fs.rmdirSync(stateHelper.tmpDir, {recursive: true}); fs.rmdirSync(stateHelper.tmpDir, {recursive: true});
core.endGroup();
} }
} }