From ed7b51b5aec31a17026ca3f4d5636e9214318a3d Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Wed, 11 Oct 2023 18:28:49 -0600 Subject: [PATCH] remove conditional and set Dockerfile + Docker Tag ahead of time Signed-off-by: Florent Poinsard --- .github/workflows/docker_build_lite.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker_build_lite.yml b/.github/workflows/docker_build_lite.yml index 6f661f0746c..afef29c5a88 100644 --- a/.github/workflows/docker_build_lite.yml +++ b/.github/workflows/docker_build_lite.yml @@ -39,22 +39,39 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set Dockerfile path + run: | + if [[ "${{ matrix.branch }}" == "latest" ]]; then + echo "DOCKERFILE=./docker/lite/Dockerfile" >> $GITHUB_ENV + else + echo "DOCKERFILE=./docker/lite/Dockerfile.${{ matrix.branch }}" >> $GITHUB_ENV + fi + - name: Build and push on main if: github.ref == 'refs/heads/main' uses: docker/build-push-action@v5 with: - file: ${{ (matrix.branch == 'latest') && './docker/lite/Dockerfile' || './docker/lite/Dockerfile.' matrix.branch }} + file: ${{ env.DOCKERFILE }} push: true tags: vitess/lite:${{ matrix.branch }} - - name: Get the tag name + - name: Get the Git tag if: startsWith(github.ref, 'refs/tags/') run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Set Docker tag name + if: startsWith(github.ref, 'refs/tags/') + run: | + if [[ "${{ matrix.branch }}" == "latest" ]]; then + echo "DOCKER_TAG=vitess/lite:${TAG_NAME}" >> $GITHUB_ENV + else + echo "DOCKER_TAG=vitess/lite:${TAG_NAME}-${{ matrix.branch }}" >> $GITHUB_ENV + fi + - name: Build and push on main if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v5 with: - file: ${{ (matrix.branch == 'latest') && './docker/lite/Dockerfile' || './docker/lite/Dockerfile.' matrix.branch }} + file: ${{ env.DOCKERFILE }} push: true - tags: ${{ (matrix.branch == 'latest' && 'vitess/lite:' env.TAG_NAME) || ('vitess/lite:' env.TAG_NAME '-' matrix.branch) }} \ No newline at end of file + tags: ${{ env.DOCKER_TAG }} \ No newline at end of file