diff --git a/go.mod b/go.mod index 18a66b6..26e0014 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/joshdk/actions-docker-shim go 1.21 + +require github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..287f6fa --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/main.go b/main.go index 8b0bded..8bfe3f1 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "os" "github.com/joshdk/actions-docker-shim/docker" + flag "github.com/spf13/pflag" ) func main() { @@ -22,7 +23,13 @@ func main() { //nolint:forbidigo,wsl func mainCmd() error { - image := fmt.Sprintf("ghcr.io/%s:%s", os.Getenv("GITHUB_REPOSITORY"), os.Getenv("GITHUB_ACTION_REF")) + var image string + flag.StringVar(&image, "image", "", "ghcr.io image to run") + flag.Parse() + + if image == "" { + image = fmt.Sprintf("ghcr.io/%s:%s", os.Getenv("GITHUB_REPOSITORY"), os.Getenv("GITHUB_ACTION_REF")) + } var token string if value := os.Getenv("GITHUB_TOKEN"); value != "" {