diff --git a/README.md b/README.md index b7a11630..53bed9bf 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/action.yml b/action.yml index 77342755..4f919359 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/src/run-on-arch.js b/src/run-on-arch.js index c2e661ef..669a0a0a 100644 --- a/src/run-on-arch.js +++ b/src/run-on-arch.js @@ -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() { @@ -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('-'));