Skip to content

Commit bcca4c9

Browse files
committed
Move release name to Docker tag instead of image name.
1 parent deb9c8b commit bcca4c9

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ jobs:
401401
402402
docker:
403403
needs: parse
404-
if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true) }}
404+
if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-') == true) }}
405405
runs-on: ubuntu-20.04
406406

407407
steps:
@@ -416,20 +416,19 @@ jobs:
416416
id: branch_substring
417417
with:
418418
value: ${{ env.GITHUB_REF_SLUG }}
419-
index_of_str: "release"
419+
index_of_str: "release-"
420420
fail_if_not_found: false
421421
default_return_value: ""
422422

423423
- name: Build images
424-
if: ${{ github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true }}
425424
run: |
426-
export BRANCH=${{ steps.branch_substring.outputs.substring }}
427-
docker build -t codecompass:dev -t modelcpp/codecompass$BRANCH:dev --file docker/dev/Dockerfile .
428-
docker build -t codecompass:runtime -t modelcpp/codecompass$BRANCH:runtime-sqlite --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=sqlite .
429-
docker build -t codecompass:web -t modelcpp/codecompass$BRANCH:web-sqlite --file docker/web/Dockerfile --no-cache .
430-
docker build -t codecompass:runtime -t modelcpp/codecompass$BRANCH:runtime-pgsql --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=pgsql .
431-
docker build -t codecompass:web -t modelcpp/codecompass$BRANCH:web-pgsql --file docker/web/Dockerfile --no-cache .
432-
docker tag modelcpp/codecompass$BRANCH:runtime-pgsql modelcpp/codecompass$BRANCH:latest
425+
BRANCH_PREFIX=${{ steps.branch_substring.outputs.substring }}
426+
BRANCH_PREFIX=${BRANCH_PREFIX}${BRANCH_PREFIX:+-} # append dash if not empty
427+
docker build -t codecompass:dev -t modelcpp/codecompass:${BRANCH_PREFIX}dev --file docker/dev/Dockerfile .
428+
docker build -t codecompass:runtime -t modelcpp/codecompass:${BRANCH_PREFIX}runtime-sqlite --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=sqlite .
429+
docker build -t codecompass:web -t modelcpp/codecompass:${BRANCH_PREFIX}web-sqlite --file docker/web/Dockerfile --no-cache .
430+
docker build -t codecompass:runtime -t modelcpp/codecompass:${BRANCH_PREFIX}runtime-pgsql --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=pgsql .
431+
docker build -t codecompass:web -t modelcpp/codecompass:${BRANCH_PREFIX}web-pgsql --file docker/web/Dockerfile --no-cache .
433432
434433
- name: Login to DockerHub
435434
uses: docker/login-action@v1
@@ -438,19 +437,24 @@ jobs:
438437
password: ${{ secrets.DOCKER_PASSWORD }}
439438

440439
- name: Push images
441-
if: ${{ github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true }}
442440
run: |
443-
export BRANCH=${{ steps.branch_substring.outputs.substring }}
444-
docker push modelcpp/codecompass$BRANCH:dev
445-
docker push modelcpp/codecompass$BRANCH:runtime-sqlite
446-
docker push modelcpp/codecompass$BRANCH:runtime-pgsql
447-
docker push modelcpp/codecompass$BRANCH:web-sqlite
448-
docker push modelcpp/codecompass$BRANCH:web-pgsql
449-
docker push modelcpp/codecompass$BRANCH:latest
441+
BRANCH_PREFIX=${{ steps.branch_substring.outputs.substring }}
442+
BRANCH_PREFIX=${BRANCH_PREFIX}${BRANCH_PREFIX:+-} # append dash if not empty
443+
docker push modelcpp/codecompass:${BRANCH_PREFIX}dev
444+
docker push modelcpp/codecompass:${BRANCH_PREFIX}runtime-sqlite
445+
docker push modelcpp/codecompass:${BRANCH_PREFIX}runtime-pgsql
446+
docker push modelcpp/codecompass:${BRANCH_PREFIX}web-sqlite
447+
docker push modelcpp/codecompass:${BRANCH_PREFIX}web-pgsql
448+
449+
- name: Tag and push latest image
450+
if: ${{ github.ref_name == 'master' }}
451+
run: |
452+
docker tag modelcpp/codecompass:runtime-pgsql modelcpp/codecompass:latest
453+
docker push modelcpp/codecompass:latest
450454
451455
tarball:
452456
needs: parse
453-
if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true) }}
457+
if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-') == true) }}
454458
runs-on: ubuntu-20.04
455459

456460
steps:

0 commit comments

Comments
 (0)