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

Allow overriding the containerName #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The action also accepts some optional input parameters:
* `setup`: Shell commands to execute on the host before running the container, such as creating directories for volume mappings.
* `install`: Shell commands to execute in the container as part of `docker build`, such as installing dependencies. This speeds up subsequent builds if `githubToken` is also used, but note that the image layer will be publicly available in your projects GitHub Package Registry, so make sure the resulting image does not have any secrets cached in logs or state.
* `base_image`: Specify a custom base image, such as [busybox](https://hub.docker.com/_/busybox), `arch` and `distro` should be set to `none` in this case. This will allow you to chose direcly the image that will be used in the *FROM* clause of the internal docker container without needing to create a Dockerfile.arch.distro for a specific arch/distro pair. For more detials, see [PR #103](https://github.com/uraimo/run-on-arch-action/pull/103#issuecomment-1363810049). Known limitation: Only one base_image configuration for each workflow if you use GitHub images caching.

* `cachedImageTag`: Allows to override the image tag that is used when caching Docker images in your project's public package registry. It is coerced to adhere to the [specification](https://docs.docker.com/engine/reference/commandline/tag/).
### Basic example

A basic example that sets an output variable for use in subsequent steps:
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ inputs:
description: 'Specify a custom base image, such as \"busybox\" or your predefined base image. This will replace the \"FROM\" claus in the default Dockerfile on the fly. This is optional. Hint: with this option you are able to use all the available archs other than the ones showed by default. See the [advanced example](./.github/workflows/advanced-example.yml) in this repo. For more detials, see [PR #103](https://github.com/uraimo/run-on-arch-action/pull/103#issuecomment-1363810049).'
required: false
default: ''
cachedImageTag:
description: 'Allows overriding the name image tag that is used for caching Docker images. It is coerced to
adhere to the [specification](https://docs.docker.com/engine/reference/commandline/tag/).'
required: false
default: ''


runs:
using: 'node16'
Expand Down
14 changes: 12 additions & 2 deletions src/run-on-arch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ const shlex = require('shlex');
const { exec } = require('@actions/exec');

function slug(str) {
return str.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase();
// From https://docs.docker.com/engine/reference/commandline/tag/
//
// A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores,
// periods and hyphens. A tag name may not start with a period or a hyphen and may contain a maximum
// of 128 characters.
//
// - Apparently, docker client on ubuntu does not adhere to the above in that it does not allow
// uppercase. The specs clearly talk about lowercase for the repository (host) name but NOT
// the tag name. Oh well.
return str.replace(/[^a-zA-Z0-9_\-\.]/g, '-').replace(/^[\.\-]+/, '').substring(0, 128).toLowerCase();
}

async function main() {
Expand Down Expand Up @@ -117,8 +126,9 @@ async function main() {
});
}

const override = core.getInput('cachedImageTag');
// Generate a container name slug unique to this workflow
const containerName = slug([
const containerName = (override) ? slug(override) : slug([
'run-on-arch', env.GITHUB_REPOSITORY, env.GITHUB_WORKFLOW,
arch, distro,
].join('-'));
Expand Down