From e16b8850db5634d0b02ec32c353a63dab121d1b6 Mon Sep 17 00:00:00 2001 From: karodadyan Date: Sat, 21 Dec 2024 01:03:30 +0400 Subject: [PATCH] Merge remote-tracking branch 'origin/main' # Conflicts: # .github/workflows/main.yml --- .github/workflows/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4d9997..865fb79 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,13 +20,13 @@ jobs: - name: Set Version, Build Number, and Repository Name id: set_version run: | - VERSION="1.0.0" - IMAGE_NAME="${{ secrets.DOCKERHUB_USERNAME }}/karos-repo" + VERSION="prod_" + REPO_NAME="${{ github.repository }}" # Fetch the full repository name (owner/repo) + REPO_NAME_ONLY=$(echo $REPO_NAME | cut -d '/' -f 2) # Extract just the repo name (after /) BUILD_NUMBER=${{ github.run_number }} - REPO_NAME="${{ github.repository }}" # Fetch repository name # Check if the version already exists on Docker Hub - if docker pull $IMAGE_NAME:$VERSION 2>/dev/null; then + if docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${REPO_NAME_ONLY}:$VERSION 2>/dev/null; then # Extract the current major and minor version MAJOR=$(echo $VERSION | cut -d '.' -f 1) MINOR=$(echo $VERSION | cut -d '.' -f 2) @@ -37,8 +37,8 @@ jobs: VERSION="$MAJOR.$MINOR.$PATCH" fi - # Combine version, build number, and repository name - TAG="$REPO_NAME-$VERSION-build.$BUILD_NUMBER" + # Combine version and build number + TAG="$REPO_NAME_ONLY:$VERSION-build.$BUILD_NUMBER" # Export variables echo "VERSION=$VERSION" >> $GITHUB_ENV @@ -49,7 +49,7 @@ jobs: run: | docker build . \ --file Dockerfile \ - --tag ${{ secrets.DOCKERHUB_USERNAME }}/karos-repo:${{ env.TAG }} + --tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.TAG }} - name: Docker Push - run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/karos-repo:${{ env.TAG }} + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.TAG }}