Skip to content

Commit

Permalink
fix(CD): mltiple tags
Browse files Browse the repository at this point in the history
  • Loading branch information
otahirs authored Sep 12, 2024
1 parent c075892 commit 4626123
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/backend_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Image Tag
- name: Determine Docker Image Tag
id: tag
run: |
# Try to find a Git tag, otherwise use the short commit hash
TAG=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)
echo "Tag or Commit: $TAG"
echo "::set-output name=image_tag::$TAG"
# Check if the current commit has a tag
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
if [ -z "$TAG" ]; then
# No tag found, use the short commit hash as the tag
TAG=$(git rev-parse --short HEAD)
fi
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Build and Publish Docker Image
working-directory: backend
run: |
# Build the Docker image and tag it with both the dynamic tag and 'latest'
./gradlew bootBuildImage \
--imageName=ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.tag }} \
--imageName=ghcr.io/${{ github.repository }}:latest
./gradlew bootBuildImage --imageName=ghcr.io/${{ github.repository }}:${{ env.TAG }}
./gradlew bootBuildImage --imageName=ghcr.io/${{ github.repository }}:latest
- name: Verify image
run: docker images

0 comments on commit 4626123

Please sign in to comment.