Skip to content

Commit

Permalink
Set docker tag in consistent manner (#2096)
Browse files Browse the repository at this point in the history
b/316402019
  • Loading branch information
andrewsavage1 committed Dec 15, 2023
1 parent 9ac239b commit 7a34f86
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/actions/docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,22 @@ runs:
# We need to set docker tag properly for pull requests. In those scenarios where no docker related files
# were changed we need to use an existing image (e.g. main). In cases where docker image is rebuilt we have
# to use tag generated by the image build.
- name: Retrieve Docker metadata for PR
id: pr-meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: ${{env.REGISTRY}}/${{github.repository}}/${{inputs.docker_image}}
tags: type=raw,value=${{ github.base_ref }}
- name: Set Docker Tag
id: set-docker-tag-presubmit-non-fork
env:
REPO: ${{ github.repository }}
if: ${{ (steps.changed-files.outputs.any_changed == 'false') && (github.event_name == 'pull_request') }}
run: echo "DOCKER_TAG=ghcr.io/${REPO}/${{inputs.docker_image}}:${GITHUB_BASE_REF%.1+}" >> $GITHUB_ENV
run: |
set -x
docker_tag="${{ steps.pr-meta.outputs.tags }}"
docker_tag="${docker_tag%.1[+,-]}"
echo "DOCKER_TAG=${docker_tag}" >> $GITHUB_ENV
shell: bash
- name: Set up Cloud SDK
if: ${{ (steps.changed-files.outputs.any_changed == 'true') && (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.fork) }}
Expand Down

0 comments on commit 7a34f86

Please sign in to comment.