From 52327cdd4c91d85fef3527a18f108e5205f37747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Cser=C3=A9p?= Date: Mon, 24 Jan 2022 13:41:02 +0100 Subject: [PATCH] Move release name to Docker tag instead of image name. --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0d0395e5..2572c2ddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -401,7 +401,7 @@ jobs: docker: needs: parse - if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true) }} + if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release/') == true) }} runs-on: ubuntu-20.04 steps: @@ -416,20 +416,19 @@ jobs: id: branch_substring with: value: ${{ env.GITHUB_REF_SLUG }} - index_of_str: "release" + index_of_str: "release-" fail_if_not_found: false default_return_value: "" - name: Build images - if: ${{ github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true }} run: | - export BRANCH=${{ steps.branch_substring.outputs.substring }} - docker build -t codecompass:dev -t modelcpp/codecompass$BRANCH:dev --file docker/dev/Dockerfile . - docker build -t codecompass:runtime -t modelcpp/codecompass$BRANCH:runtime-sqlite --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=sqlite . - docker build -t codecompass:web -t modelcpp/codecompass$BRANCH:web-sqlite --file docker/web/Dockerfile --no-cache . - docker build -t codecompass:runtime -t modelcpp/codecompass$BRANCH:runtime-pgsql --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=pgsql . - docker build -t codecompass:web -t modelcpp/codecompass$BRANCH:web-pgsql --file docker/web/Dockerfile --no-cache . - docker tag modelcpp/codecompass$BRANCH:runtime-pgsql modelcpp/codecompass$BRANCH:latest + BRANCH_PREFIX=${{ steps.branch_substring.outputs.substring }} + BRANCH_PREFIX=${BRANCH_PREFIX}${BRANCH_PREFIX:+-} # append dash if not empty + docker build -t codecompass:dev -t modelcpp/codecompass:${BRANCH_PREFIX}dev --file docker/dev/Dockerfile . + docker build -t codecompass:runtime -t modelcpp/codecompass:${BRANCH_PREFIX}runtime-sqlite --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=sqlite . + docker build -t codecompass:web -t modelcpp/codecompass:${BRANCH_PREFIX}web-sqlite --file docker/web/Dockerfile --no-cache . + docker build -t codecompass:runtime -t modelcpp/codecompass:${BRANCH_PREFIX}runtime-pgsql --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=pgsql . + docker build -t codecompass:web -t modelcpp/codecompass:${BRANCH_PREFIX}web-pgsql --file docker/web/Dockerfile --no-cache . - name: Login to DockerHub uses: docker/login-action@v1 @@ -438,19 +437,24 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Push images - if: ${{ github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true }} run: | - export BRANCH=${{ steps.branch_substring.outputs.substring }} - docker push modelcpp/codecompass$BRANCH:dev - docker push modelcpp/codecompass$BRANCH:runtime-sqlite - docker push modelcpp/codecompass$BRANCH:runtime-pgsql - docker push modelcpp/codecompass$BRANCH:web-sqlite - docker push modelcpp/codecompass$BRANCH:web-pgsql - docker push modelcpp/codecompass$BRANCH:latest + BRANCH_PREFIX=${{ steps.branch_substring.outputs.substring }} + BRANCH_PREFIX=${BRANCH_PREFIX}${BRANCH_PREFIX:+-} # append dash if not empty + docker push modelcpp/codecompass:${BRANCH_PREFIX}dev + docker push modelcpp/codecompass:${BRANCH_PREFIX}runtime-sqlite + docker push modelcpp/codecompass:${BRANCH_PREFIX}runtime-pgsql + docker push modelcpp/codecompass:${BRANCH_PREFIX}web-sqlite + docker push modelcpp/codecompass:${BRANCH_PREFIX}web-pgsql + + - name: Tag and push latest image + if: ${{ github.ref_name == 'master' }} + run: | + docker tag modelcpp/codecompass:runtime-pgsql modelcpp/codecompass:latest + docker push modelcpp/codecompass:latest tarball: needs: parse - if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release') == true) }} + if: ${{ github.repository == 'Ericsson/CodeCompass' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release/') == true) }} runs-on: ubuntu-20.04 steps: