From 994c213420c6531495332452652fb9129184704b 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 --- act/runner/step_context.go | 3 ++- act/runner/testdata/local-action-dockerfile/push.yml | 1 + act/runner/testdata/localdockerimagetest_/Dockerfile | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 act/runner/testdata/localdockerimagetest_/Dockerfile diff --git a/act/runner/step_context.go b/act/runner/step_context.go index 372c594a..5d642415 100644 --- a/act/runner/step_context.go +++ b/act/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/act/runner/testdata/local-action-dockerfile/push.yml b/act/runner/testdata/local-action-dockerfile/push.yml index 06f9f4c7..3a76107b 100644 --- a/act/runner/testdata/local-action-dockerfile/push.yml +++ b/act/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/act/runner/testdata/localdockerimagetest_/Dockerfile b/act/runner/testdata/localdockerimagetest_/Dockerfile new file mode 100644 index 00000000..94798c1d --- /dev/null +++ b/act/runner/testdata/localdockerimagetest_/Dockerfile @@ -0,0 +1,2 @@ +FROM ubuntu:latest +CMD echo Hello