-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Running a build with empty build args builds and pushes an image with no name #80
Comments
I'm having this issue too. I started from the Cloud Run example maintained by GCP (https://github.com/GoogleCloudPlatform/github-actions/tree/master/example-workflows/cloud-run). It worked perfectly, but I figured it was a waste to use my Cloud Build minutes to build the image, since GitHub Actions was just waiting for Cloud Build to build the image. I figured I'd swap out the Cloud Build part of that workflow for a generic "build and push" step that would push to GCR. That led me to this action. My workflow step follows the style in the README in this repo: - name: Build and push Docker image to Google Container Registry
uses: docker/build-push-action@v1.1.0
with:
username: _json_key
password: ${{ secrets.RUN_SA_KEY }}
registry: gcr.io
repository: ${{ secrets.RUN_PROJECT }}/${{ env.SERVICE_NAME }}
tags: ${{ env.GITHUB_SHA }} (note that I added the "Cloud Storage Admin" role to the service account created when following the Cloud Run example README, so that my service account could be used to push the image to GCR too) But, when it runs, it does the build but finishes with this in the logs:
And when I check GCR, I don't see a repository for the repository name I chose in this workflow. My Dockerfile is something I grabbed when googling for a standard multi stage Go build: # Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.14 as builder
# Create and change to the app directory.
WORKDIR /app
# Retrieve application dependencies using go modules.
# Allows container builds to reuse downloaded dependencies.
COPY go.* ./
RUN go mod download
# Copy local code to the container image.
COPY . ./
# Build the binary.
# -mod=readonly ensures immutable go.mod and go.sum in container builds.
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o server
# Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3
RUN apk add --no-cache ca-certificates
# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/server /server
# Run the web service on container startup.
CMD ["/server"]
I checked out #37 and my GitHub repo name has no uppercase characters, it's just eight lowercase characters with no separators, so I don't think it's related. UPDATE: After replacing that step in my workflow with a manual step that used the credential helper for GCR and built and pushed using Bash commands, it worked:
I ended up with the image in my project's GCR after this, and the logs display the image being pushed properly:
|
@mattwelke glad to hear you got it working. I was able to fix my builds as well, by correcting the build args in my case. In terms of the preferred behavior for this action though, if the action doesn't receive a name, it should stop and throw an error, rather than wasting time going through the entire build and push process. |
I think my issue is about a more core issue though. I don't see anything complex about my Dockerfile. I'm not using build args and as far as I can tell, I'm specifying the name of the image to be built properly. I don't understand why my push fails just because it's to GCR. |
Version 2 has been merged to the main branch and is therefore available via As a reminder, this new version changes drastically and works with 3 new actions (login, setup-buildx and setup-qemu) that we have created. Many usage examples have been added to handle most use cases. This new version should fix your issue. Don't hesitate if you have any questions. |
Is there an example for defining Docker I wanted to do something like this |
Description
I recently ran this action in a workflow, with my repo name nicely lowercased (#37), but had one of my build args configured incorrectly. Note the environment variable
BUILD_env=test
, which should have beenBUILD_ENV=test
. My Dockerfile has default build args set (likeARG BUILD_ENV=development
), but the build arg here was probably overwriting that. My bad.However, the action actually sets the image name to
[]
, kicks off a Docker build, completes the build, and attempts to push an image named[]
.Specific image name below replaced with
org/repo/image
.Suggestions
Related
#37
#41
The text was updated successfully, but these errors were encountered: