added specifications api #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Backend App | |
on: | |
push: | |
branches: | |
- main # Trigger on push to the main branch | |
jobs: | |
deploy: | |
name: Build and Deploy Backend App | |
runs-on: ['self-hosted', 'Linux', 'X64'] | |
steps: | |
# Step 1: Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Java environment | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' # Use Eclipse Temurin for Java | |
java-version: '17' # Specify the Java version | |
# Step 3: Build the application using Maven | |
- name: Copy application-production.properties | |
run: | | |
#Ensure the resources folder exists | |
mkdir -p src/main/resources | |
# Copy the properties file from the server to the resources folder | |
cp /home/thanau/properties/application-production.properties src/main/resources/ | |
- name: Build Java application | |
run: | | |
mvn clean package -DskipTests -Pproduction | |
env: | |
JAVA_HOME: ${{ steps.setup-java.outputs.java-home }} | |
# Step 4: Deploy the built JAR file | |
- name: Deploy Application | |
run: | | |
# Stop the service | |
sudo -S <<< 1 systemctl stop thanau-backend | |
# Move the new build to the deployment directory | |
mv target/*.jar /var/www/app/thanaustore/backendapp.jar | |
# Restart the service | |
sudo -S <<< 1 systemctl restart thanau-backend |