Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 8aeb8cc

Browse files
CI: set proper docker image version for PRs against stable branches
This solution is copy-pasted from pmemkv (70cd9e4). Without this change PRs created against any stable branch may end up failing, because it uses 'latest' image, instead of proper stable (e.g. '1.13') image.
1 parent 9357d94 commit 8aeb8cc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.github/workflows/gha.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ jobs:
4848
echo "FORCE_IMAGE_ACTION=rebuild" >> $GITHUB_ENV
4949
5050
- name: Set image version and force image action for stable branch
51-
if: startsWith(github.ref, 'refs/heads/stable-')
51+
# we want to set IMG_VER to e.g. '1.x' for stable branches and PRs against them
52+
# for PRs we have to use 'base_ref' - this is the target branch (and we have to check that instead)
53+
if:
54+
startsWith(github.ref, 'refs/heads/stable-') || startsWith(github.base_ref, 'stable-')
55+
# we now know we're on (or against) stable branches, so we just need to pick the version (e.g. the mentioned '1.x')
5256
run: |
53-
echo "IMG_VER=$(echo ${GITHUB_REF#refs/heads/} | cut -d - -f 2)" >> $GITHUB_ENV
57+
IMG_VER=$(echo ${GITHUB_BASE_REF} | cut -d - -f 2)
58+
[ -z "${IMG_VER}" ] \
59+
&& echo "IMG_VER=$(echo ${GITHUB_REF#refs/heads/} | cut -d - -f 2)" >> $GITHUB_ENV \
60+
|| echo "IMG_VER=${IMG_VER}" >> $GITHUB_ENV
5461
echo "FORCE_IMAGE_ACTION=rebuild" >> $GITHUB_ENV
5562
5663
- name: Clone the git repo

0 commit comments

Comments
 (0)