From 77b396891325d2567de3ddfd8a1ce0ea204a734d Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Mon, 9 Aug 2021 20:16:31 +0200 Subject: [PATCH] Fix docker: invalid reference format (#767) * Fix local Docker actions: invalid reference format * Create Dockerfile * Create Dockerfile * Update push.yml * Revert "Create Dockerfile" This reverts commit 9d1dbbc2c7fdf52963e55feb4148ac2b14d639d0. * Fix lint * fix: re-use image that is already present in repo ubuntu:latest would pull unnecessary blobs from registry and count toward API limit * fix: revert change reverting due to issue in image deletion that will have to be investigated separately Co-authored-by: Ryan --- pkg/runner/step_context.go | 3 ++- pkg/runner/testdata/local-action-dockerfile/push.yml | 1 + pkg/runner/testdata/localdockerimagetest_/Dockerfile | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 pkg/runner/testdata/localdockerimagetest_/Dockerfile diff --git a/pkg/runner/step_context.go b/pkg/runner/step_context.go index 372c594..5d64241 100644 --- a/pkg/runner/step_context.go +++ b/pkg/runner/step_context.go @@ -506,7 +506,8 @@ func (sc *StepContext) execAsDocker(ctx context.Context, action *model.Action, a if strings.HasPrefix(action.Runs.Image, "docker://") { image = strings.TrimPrefix(action.Runs.Image, "docker://") } else { - image = fmt.Sprintf("%s:%s", regexp.MustCompile("[^a-zA-Z0-9]").ReplaceAllString(actionName, "-"), "latest") + // "-dockeraction" enshures that "./", "./test " won't get converted to "act-:latest", "act-test-:latest" which are invalid docker image names + image = fmt.Sprintf("%s-dockeraction:%s", regexp.MustCompile("[^a-zA-Z0-9]").ReplaceAllString(actionName, "-"), "latest") image = fmt.Sprintf("act-%s", strings.TrimLeft(image, "-")) image = strings.ToLower(image) basedir := actionLocation diff --git a/pkg/runner/testdata/local-action-dockerfile/push.yml b/pkg/runner/testdata/local-action-dockerfile/push.yml index 06f9f4c..3a76107 100644 --- a/pkg/runner/testdata/local-action-dockerfile/push.yml +++ b/pkg/runner/testdata/local-action-dockerfile/push.yml @@ -9,3 +9,4 @@ jobs: - uses: ./actions/docker-local with: who-to-greet: 'Mona the Octocat' + - uses: ./localdockerimagetest_ diff --git a/pkg/runner/testdata/localdockerimagetest_/Dockerfile b/pkg/runner/testdata/localdockerimagetest_/Dockerfile new file mode 100644 index 0000000..94798c1 --- /dev/null +++ b/pkg/runner/testdata/localdockerimagetest_/Dockerfile @@ -0,0 +1,2 @@ +FROM ubuntu:latest +CMD echo Hello