Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,25 @@ jobs:
java-version: '17'
distribution: 'temurin'


- name: Set Spring Profile Based on Branch
id: set-profile
run: |
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "SPRING_PROFILE=prod" >> $GITHUB_ENV
else
echo "SPRING_PROFILE=dev" >> $GITHUB_ENV
fi

- name: Verify Backend_Config files
run: ls -al Backend_Config

- name: Build and Test with Gradle Wrapper
env:
SPRING_PROFILES_ACTIVE: test
- name: Build with Gradle Wrapper
run: |
echo "β–Ά Running Gradle build and test..."
./gradlew --no-daemon clean build test \
-Dspring.profiles.active=test \
-Dspring.config.location=classpath:/,file:./Backend_Config/application-test.properties
echo "β–Ά Running Gradle bootJar with $SPRING_PROFILE profile..."
./gradlew --no-daemon clean bootJar \
-Dspring.profiles.active=$SPRING_PROFILE \
-Dspring.config.location=classpath:/,file:./Backend_Config/application-$SPRING_PROFILE.properties

- name: Show test results summary
if: success()
Expand All @@ -61,15 +69,15 @@ jobs:

- name: Find latest jar file
id: find-jar
run: echo "LATEST_JAR=$(ls -t build/libs/*.jar | head -n 1)" >> $GITHUB_ENV
run: echo "LATEST_JAR=$(find build/libs -type f -name '*.jar' ! -name '*plain*' | head -n 1)" >> $GITHUB_ENV


- name: Upload jar file to Artifact
uses: actions/upload-artifact@v4
with:
name: jar_files
path: ${{ env.LATEST_JAR }}


- name: Upload Dockerfile to Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM openjdk:17-alpine
ARG JAR_FILE=build/libs/*.jar
ARG JAR_FILE=build/libs/*-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
RUN ls -al /app.jar
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/app.jar"]
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/app.jar"]
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ task copyYml(type: Copy){
include '*.properties'
into 'src/main/resources'
}
}

tasks.withType(Jar){
enabled = false
}