Skip to content

Commit 9b45314

Browse files
authored
Skip only PR parts of docker image pull for PRs (#7823)
The rest of the pull step is needed to set the correct Docker image for subsequent steps. Bug: 376324653
1 parent 2895a23 commit 9b45314

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

.github/actions/docker/action.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ runs:
6565

6666
- name: Pull Existing Docker Image
6767
id: pull-cached-image
68-
if: inputs.is_pr == 'true'
6968
env:
7069
GITHUB_DOCKER_REGISTRY_URL: ghcr.io
7170
PR_DOCKER_REGISTRY_URL: us-central1-docker.pkg.dev
@@ -77,18 +76,20 @@ runs:
7776
set -x
7877
DOCKER_COMPOSE_IMAGE="${GITHUB_DOCKER_REGISTRY_URL}/${{ github.repository }}/${DOCKER_SERVICE}"
7978
80-
if docker manifest inspect "${DOCKER_COMPOSE_IMAGE}:${DOCKER_CONTENT_SHA}"; then
81-
# A postsubmit image exists, use it.
82-
echo "Using existing ${DOCKER_COMPOSE_IMAGE}"
79+
if [[ "$IS_PR" == "true" ]]; then
80+
if docker manifest inspect "${DOCKER_COMPOSE_IMAGE}:${DOCKER_CONTENT_SHA}"; then
81+
# A postsubmit image exists, use it.
82+
echo "Using existing ${DOCKER_COMPOSE_IMAGE}"
8383
84-
else
85-
# No fitting post-submit image was found. Check PR registry to see if there's an image there.
86-
PROJECT_NAME=$(gcloud config get-value project)
87-
DOCKER_COMPOSE_IMAGE="${PR_DOCKER_REGISTRY_URL}/${PROJECT_NAME}/github/${DOCKER_SERVICE}"
84+
else
85+
# No fitting post-submit image was found. Check PR registry to see if there's an image there.
86+
PROJECT_NAME=$(gcloud config get-value project)
87+
DOCKER_COMPOSE_IMAGE="${PR_DOCKER_REGISTRY_URL}/${PROJECT_NAME}/github/${DOCKER_SERVICE}"
8888
89-
if ! docker manifest inspect "${DOCKER_COMPOSE_IMAGE}:${DOCKER_CONTENT_SHA}"; then
90-
echo "::warning::No pre-built docker image found for tag ${DOCKER_CONTENT_SHA}."
91-
echo "build_image=true" >> $GITHUB_OUTPUT
89+
if ! docker manifest inspect "${DOCKER_COMPOSE_IMAGE}:${DOCKER_CONTENT_SHA}"; then
90+
echo "::warning::No pre-built docker image found for tag ${DOCKER_CONTENT_SHA}."
91+
echo "build_image=true" >> $GITHUB_OUTPUT
92+
fi
9293
fi
9394
fi
9495

0 commit comments

Comments
 (0)