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

Commit 5401d48

Browse files
author
Paweł Karczewski
authored
Merge pull request #1204 from lukaszstolarczuk/fix-dockerimage-version-in-CI
Fix Docker image version(s) in CI
2 parents 7bbe1d1 + 77cb381 commit 5401d48

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/gha.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Get release version
4040
if: github.event_name == 'release'
4141
id: get_release_version
42-
run: echo ::set-output name=VERSION::$(echo ${{ github.event.release.tag_name }} | grep -E "^[0-9]+.[0-9]+(-rc[0-9]+)?$" | cut -f 1,2 -d . | cut -f 1 -d -)
42+
run: echo ::set-output name=VERSION::$(echo ${{ github.event.release.tag_name }} | awk -F '[.-]' '/^[0-9]+.[0-9]+[.0-9]*(-rc[0-9]+)?$/ {print $1 "." $2}')
4343

4444
- name: Set image version and force image action for release
4545
if: github.event_name == 'release' && steps.get_release_version.outputs.VERSION != ''
@@ -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
@@ -64,6 +71,7 @@ jobs:
6471

6572
- name: Run the build
6673
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./build.sh
74+
6775
doc:
6876
name: build and publish docs
6977
runs-on: ubuntu-latest
@@ -79,6 +87,12 @@ jobs:
7987
matrix:
8088
CONFIG: ["TYPE=doc OS=fedora OS_VER=32"]
8189
steps:
90+
- name: Set image version for stable branch
91+
# doc update happens only on stable branch (not on PR), so we check only for heads ref
92+
if: startsWith(github.ref, 'refs/heads/stable-')
93+
run: |
94+
echo "IMG_VER=$(echo ${GITHUB_REF#refs/heads/} | cut -d - -f 2)" >> $GITHUB_ENV
95+
8296
- name: Clone the git repo
8397
uses: actions/checkout@v2
8498
with:

0 commit comments

Comments
 (0)