diff --git a/README.md b/README.md index 563ca62..4523d1b 100644 --- a/README.md +++ b/README.md @@ -86,14 +86,25 @@ jobs: - uses: Example/example-action@a35f...b316 ``` -If you want your action to use a different image, then you can specify one manually in `action.yml`. +If you want your action to use a specific image tag, then you can set one manually in `action.yml`. ```diff runs: using: docker image: docker://ghcr.io/joshdk/actions-docker-shim:v0.0.2 + args: -+ - --image=ghcr.io/example/example-action:snapshot ++ - --image-tag=snapshot +``` + +If your image isn't named the same as your action repository, that can be overridden as well. + +```diff +runs: + using: docker + image: docker://ghcr.io/joshdk/actions-docker-shim:v0.0.2 + args: + - --image-tag=snapshot ++ - --image=example/some-other-image ``` ### Authentication diff --git a/main.go b/main.go index f1a8fdf..1c10523 100644 --- a/main.go +++ b/main.go @@ -24,17 +24,21 @@ func main() { //nolint:forbidigo,wsl func mainCmd() error { - var image string - flag.StringVar(&image, "image", "", "ghcr.io image to run") + var imageRepo string + flag.StringVar(&imageRepo, "image", "", "ghcr.io image to run") + var imageTag string + flag.StringVar(&imageTag, "image-tag", "", "ghcr.io image tag to run") var tokenEnv string flag.StringVar(&tokenEnv, "token-env", "", "env var to use for github token") flag.Parse() - if image == "" { - repository := os.Getenv("GITHUB_ACTION_REPOSITORY") - ref := os.Getenv("GITHUB_ACTION_REF") - image = fmt.Sprintf("ghcr.io/%s:%s", strings.ToLower(repository), ref) + if imageRepo == "" { + imageRepo = os.Getenv("GITHUB_ACTION_REPOSITORY") } + if imageTag == "" { + imageTag = os.Getenv("GITHUB_ACTION_REF") + } + image := fmt.Sprintf("ghcr.io/%s:%s", strings.ToLower(imageRepo), imageTag) var token string if tokenEnv != "" {