docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.37k stars 558 forks source link

Image not being pushed with v1 #418

Closed jlunaq closed 3 years ago

jlunaq commented 3 years ago

Hey there,

I'm using v1 with the following configuration to build and publish the image:

  publish_docker:
    runs-on: [self-hosted, tsa, myrunner]
    if: github.event.action == 'closed' && github.event.pull_request.merged && !needs.release.outputs.skip
    needs: release
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Push to Docker Registry
        uses: docker/build-push-action@v1
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          registry: docker-local.registry.company.com
          repository: name/app
          build-args: GITHUB_USER=${{ secrets.GITHUB_USER }},GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
          tag_with_ref: true

When the action is ran, it seems that it builds the image correctly but it's not pushing that to the repo, it finishes with the message: Pushing image [] And when I check the repo, I see that it was not actually pushed.

Do you know why it ends like this? I mean it ends without giving any error, just that message and it doesn't do the push process

crazy-max commented 3 years ago

@jlunaq Can you post logs please?

jlunaq commented 3 years ago

Sure

Warning: Input 'repository' has been deprecated with message: v2 is now available through docker/build-push-action@v2
Warning: Unexpected input(s) 'build-args', valid inputs are ['entryPoint', 'args', 'username', 'password', 'registry', 'repository', 'tags', 'tag_with_ref', 'tag_with_sha', 'path', 'dockerfile', 'target', 'always_pull', 'build_args', 'cache_froms', 'labels', 'add_git_labels', 'push']
Run docker/build-push-action@v1
/usr/bin/docker run --name dockergithubactionsv1_3c767c --label 7784cf --workdir /github/workspace --rm -e INPUT_USERNAME -e INPUT_PASSWORD -e INPUT_REGISTRY -e INPUT_REPOSITORY -e INPUT_BUILD-ARGS -e INPUT_TAG_WITH_REF -e INPUT_PUSH -e INPUT_TAGS -e INPUT_TAG_WITH_SHA -e INPUT_PATH -e INPUT_DOCKERFILE -e INPUT_TARGET -e INPUT_ALWAYS_PULL -e INPUT_BUILD_ARGS -e INPUT_CACHE_FROMS -e INPUT_LABELS -e INPUT_ADD_GIT_LABELS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/vsts-agent/actions-runner/_work/_temp/_github_home":"/github/home" -v "/home/vsts-agent/actions-runner/_work/_temp/_github_workflow":"/github/workflow" -v "/home/vsts-agent/actions-runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/vsts-agent/actions-runner/_work/kps-name-app":"/github/workspace" docker/github-actions:v1  "build-push"
Logging in to registry docker-local.registry.company.com
WARNING! Using -*** the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /github/home/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
Building image []
Sending build context to Docker daemon  59.13MB

Step 1/18 : FROM golang:1.15 as builder
1.15: Pulling from library/golang
627b765e08d1: Already exists
c040670e5e55: Already exists
073a180f4992: Already exists
bf76209566d0: Already exists
6182a456504b: Pulling fs layer
50166d5516cc: Pulling fs layer
913fcba86651: Pulling fs layer
913fcba86651: Verifying Checksum
913fcba86651: Download complete
6182a456504b: Download complete
50166d5516cc: Verifying Checksum
50166d5516cc: Download complete
6182a456504b: Pull complete
50166d5516cc: Pull complete
913fcba86651: Pull complete
Digest: sha256:6be9d3fd669c5588c123ec1c9826f5c37958fb38c351de2ea1e3cf9e52ed77f9
Status: Downloaded newer image for golang:1.15
 ---> b7aa66f3b4ff
Step 2/18 : WORKDIR /workspace
 ---> Running in 4c54fe4a75d5
Removing intermediate container 4c54fe4a75d5
 ---> 65714adf85ef
Step 3/18 : COPY go.mod go.mod
 ---> e23587333a7e
Step 4/18 : RUN go mod download
 ---> Running in 592db96a4096
Removing intermediate container 592db96a4096
 ---> e9c35abb3b5f
Step 5/18 : COPY main.go main.go
 ---> 8910aa6658a1
Step 6/18 : COPY api/ api/
 ---> f71a98548c74
Step 7/18 : COPY controllers/ controllers/
 ---> 9745b1ad6325
Step 8/18 : COPY pkg/ pkg/
 ---> 50e6cf68a8f6
Step 9/18 : ARG GITHUB_USER
 ---> Running in 3427d4100e52
Removing intermediate container 3427d4100e52
 ---> 72238f60c79e
Step 10/18 : ARG GITHUB_TOKEN
 ---> Running in d9ed49cab6cf
Removing intermediate container d9ed49cab6cf
 ---> 3c751db15c70
Step 11/18 : RUN printf "machine github.com\n    login ${GITHUB_USER}\n    password ${GITHUB_TOKEN}\n    \n    machine api.github.com\n    login ${GITHUB_USER}\n    password ${GITHUB_TOKEN}\n"    >> /root/.netrc
 ---> Running in 854d09057de1
Removing intermediate container 854d09057de1
 ---> 9418834e0d93
Step 12/18 : RUN chmod 600 /root/.netrc
 ---> Running in bb509abe03a4
Removing intermediate container bb509abe03a4
 ---> 2927b0c8ebd6
Step 13/18 : RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
 ---> Running in 4534b2c155c2
Removing intermediate container 4534b2c155c2
 ---> 9a789de6dc5e
Step 14/18 : FROM gcr.io/distroless/static:nonroot
nonroot: Pulling from distroless/static
0d7d70899875: Pulling fs layer
0d7d70899875: Verifying Checksum
0d7d70899875: Download complete
0d7d70899875: Pull complete
Digest: sha256:c9f9b040044cc23e1088772814532d90adadfa1b86dcba17d07cb567db18dc4e
Status: Downloaded newer image for gcr.io/distroless/static:nonroot
 ---> ab737430e80b
Step 15/18 : WORKDIR /
 ---> Running in 531afb9f8053
Removing intermediate container 531afb9f8053
 ---> 1dde695981ec
Step 16/18 : COPY --from=builder /workspace/manager .
 ---> 7a5915209768
Step 17/18 : USER nonroot:nonroot
 ---> Running in ff78357e9f0c
Removing intermediate container ff78357e9f0c
 ---> 50b8e958df4a
Step 18/18 : ENTRYPOINT ["/manager"]
 ---> Running in e3ebe1e4c86f
Removing intermediate container e3ebe1e4c86f
 ---> b98621640d3d
Successfully built b98621640d3d
Pushing image []
jlunaq commented 3 years ago

I think that for some reason the action is not reading the tag value, because it appears as empty. The last line, should look like Pushing image [docker-local.registry.company.com/name/app:v4.7.0]

crazy-max commented 3 years ago

It might be an event that is not handled to generate tags. Can't really tell without the complete workflow.

Anyway, I suggest to migrate to docker/build-push-action@v2 as v1 is deprecated. To handle tags and labels with v2 see https://github.com/docker/build-push-action/blob/master/docs/advanced/tags-labels.md.

jlunaq commented 3 years ago

Finally I made it work by adding the tags input. And yeah, I'm considering to migrate to v2. Thanks