From 96bebcba0af124af1635048000a41ceed9c28478 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Tue, 16 Jul 2024 15:37:10 +0700 Subject: [PATCH] Unify script --- .github/workflows/docker-release.yml | 34 +++++++++------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 816acaf5..51000c5d 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -24,37 +24,25 @@ jobs: steps: - name: Log in to registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - # - - name: Push UI image + - name: Refine release version run: | - IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$UI_IMAGE_NAME - - # This changes all uppercase characters to lowercase. - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') # This strips the git ref prefix from the version. VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # This strips the "v" prefix from the tag name. [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') # This uses the Docker `latest` tag convention. [ "$VERSION" == "main" ] && VERSION=latest - echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION - docker tag $UI_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + - name: Push UI image + run: | + UI_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$UI_IMAGE_NAME + echo IMAGE_ID=$UI_IMAGE_ID + docker tag $UI_IMAGE_NAME $UI_IMAGE_ID:$VERSION + docker push $UI_IMAGE_ID:$VERSION - name: Push Service image run: | - IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$SERVICE_IMAGE_NAME - - # This changes all uppercase characters to lowercase. - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # This strips the git ref prefix from the version. - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - # This strips the "v" prefix from the tag name. - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # This uses the Docker `latest` tag convention. - [ "$VERSION" == "main" ] && VERSION=latest - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION \ No newline at end of file + SERVICE_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$SERVICE_IMAGE_NAME + echo IMAGE_ID=$SERVICE_IMAGE_ID + docker tag $SERVICE_IMAGE_NAME $SERVICE_IMAGE_ID:$VERSION + docker push $SERVICE_IMAGE_ID:$VERSION \ No newline at end of file