diff --git a/.github/workflows/build_ghcr.yml b/.github/workflows/build_ghcr.yml index f608f73..13e811a 100644 --- a/.github/workflows/build_ghcr.yml +++ b/.github/workflows/build_ghcr.yml @@ -50,6 +50,20 @@ jobs: id: branch-name uses: tj-actions/branch-names@v5.2 + - name: Get a Docker-ready tag + id: docker-tag + run: | + # Get lowercase repo and actor names + REPO_NAME=$(echo "${{ github.repository }}" | awk -F'/' '{print tolower($2)}') + ACTOR_NAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') + BRANCH_NAME=$(echo "${{ steps.branch-name.outputs.current_branch }}" | sed 's/[^a-zA-Z0-9]/-/g; s/[A-Z]/\L&/g') + + # Build Docker tag + echo "CUSTOM_TAG=${{ env.REGISTRY }}/${ACTOR_NAME}/${REPO_NAME}:${BRANCH_NAME}" >> $GITHUB_ENV + + # Debug output + echo "Generated Tag: ${{ env.CUSTOM_TAG }}" + - name: Build and push Docker image uses: docker/build-push-action@v2 with: @@ -63,7 +77,7 @@ jobs: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest # Push to branch-specific tag - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.branch-name.outputs.current_branch | replace('refs/heads/', '') }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.CUSTOM_TAG }} # Push to stable if on main branch ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:stable