Skip to content

fix(CD): gradlew path #2

fix(CD): gradlew path

fix(CD): gradlew path #2

name: Publish Docker Image
on:
push:
branches:
- main
workflow_dispatch: # Manual trigger
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '21'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Get the Git commit hash
id: vars
run: |
# Get commit hash
echo "GIT_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# Get the tag if exists
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
echo "GIT_TAG=$TAG" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Publish Docker Image
run: ./backend/gradlew bootBuildImage
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_TAG: ${{ env.GIT_TAG }} # Pass the tag to Gradle
GIT_COMMIT_HASH: ${{ env.GIT_COMMIT_HASH }} # Pass the commit hash to Gradle
- name: Verify image
run: docker images