RafikFarhad / push-to-gcr-github-action

An action that build docker image and push to Google Cloud Registry and Google Artifact Registry.
MIT License
68 stars 37 forks source link

Github Workflow executes forever if Docker build fails. #24

Closed MisterJimson closed 2 years ago

MisterJimson commented 2 years ago

We introduced a bug that caused the docker file to fail to build. I would expect the Github workflow to exit with an error.

Instead the publish to GCR step just continues forever. This uses up build time and makes debugging the problem difficult.

RafikFarhad commented 2 years ago

I am thinking about what type of solution will be suitable here. Maybe a timeout for publishing to GCR step? Do you have any suggestions?

MisterJimson commented 2 years ago

Locally the docker build command exists with a non-zero exit code. So I would want the action to propagate that exit code out to the action.

As an example

    if docker build .; then
        echo worked
    else
        echo failed
    fi

When I run that bash script, the docker build starts, fails, then I see "failed" as the output. We should be able to capture the exit code and fail the workflow step.

RafikFarhad commented 2 years ago

Are not we doing the same here: https://github.com/RafikFarhad/push-to-gcr-github-action/blob/master/entrypoint.sh#L57-L62

    if docker build $BUILD_PARAMS $TARGET_ARG -t $TEMP_IMAGE_NAME $FILE_ARG $INPUT_CONTEXT; then
        echo "Image built ..."
    else
        echo "Image building failed. Exiting ..."
        exit 1
    fi
MisterJimson commented 2 years ago

Wow. Hmm. Maybe it's something with my specific setup. I'll spend some more time debugging and try to find what I can.

RafikFarhad commented 2 years ago

Thanks, @MisterJimson for using this action for sharing your valuable suggestion. Seems like it has been no longer an issue for you so closing this.