Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove os limitation #349

Merged
merged 1 commit into from Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified .github/build-push-action.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -207,6 +207,37 @@ jobs:
uses: crazy-max/ghaction-dump-context@v1

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
steps:
-
Expand Down
5 changes: 0 additions & 5 deletions README.md
Expand Up @@ -43,7 +43,6 @@ ___
* [outputs](#outputs)
* [Troubleshooting](#troubleshooting)
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
* [Limitation](#limitation)

## Usage

Expand Down Expand Up @@ -243,7 +242,3 @@ updates:
schedule:
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).
6 changes: 6 additions & 0 deletions TROUBLESHOOTING.md
@@ -1,6 +1,8 @@
# Troubleshooting

* [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

Expand All @@ -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
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)
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
following workflow. If it works then open an issue on [buildkit](https://github.com/moby/buildkit) repository.

Expand Down
23 changes: 13 additions & 10 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion src/buildx.ts
Expand Up @@ -100,7 +100,7 @@ export async function getVersion(): Promise<string> {
export async function parseVersion(stdout: string): Promise<string> {
const matches = /\sv?([0-9.]+)/.exec(stdout);
if (!matches) {
throw new Error(`Cannot parse Buildx version`);
throw new Error(`Cannot parse buildx version`);
}
return semver.clean(matches[1]);
}
21 changes: 12 additions & 9 deletions src/main.ts
@@ -1,5 +1,4 @@
import * as fs from 'fs';
import * as os from 'os';
import * as buildx from './buildx';
import * as context from './context';
import * as exec from './exec';
Expand All @@ -8,22 +7,24 @@ import * as core from '@actions/core';

async function run(): Promise<void> {
try {
if (os.platform() !== 'linux') {
throw new Error(`Only supported on linux platform`);
}
core.startGroup(`Docker info`);
await exec.exec('docker', ['version']);
await exec.exec('docker', ['info']);
core.endGroup();

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());

const buildxVersion = await buildx.getVersion();
core.info(`📣 Buildx version: ${buildxVersion}`);
core.info(`Using buildx ${buildxVersion}`);

const defContext = context.defaultContext();
let inputs: context.Inputs = await context.getInputs(defContext);

core.info(`🏃 Starting build...`);
core.info(`Building...`);
const args: string[] = await context.getArgs(inputs, defContext, buildxVersion);
await exec.exec('docker', args).then(res => {
if (res.stderr != '' && !res.success) {
Expand All @@ -33,9 +34,10 @@ async function run(): Promise<void> {

const imageID = await buildx.getImageID();
if (imageID) {
core.info('🛒 Extracting digest...');
core.startGroup(`Extracting digest`);
core.info(`${imageID}`);
core.setOutput('digest', imageID);
core.endGroup();
}
} catch (error) {
core.setFailed(error.message);
Expand All @@ -44,8 +46,9 @@ async function run(): Promise<void> {

async function cleanup(): Promise<void> {
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});
core.endGroup();
}
}

Expand Down