Skip to content

Build and Deploy Marketplace-Service on branch feature/MARP-277-Sonar-forSpringBoot by nqhoan-axonivy #11

Build and Deploy Marketplace-Service on branch feature/MARP-277-Sonar-forSpringBoot by nqhoan-axonivy

Build and Deploy Marketplace-Service on branch feature/MARP-277-Sonar-forSpringBoot by nqhoan-axonivy #11

Workflow file for this run

name: DEV Build
run-name: Build and Deploy Marketplace-Service on branch ${{github.ref_name}} by ${{github.actor}}
on:
push:
branches: [ "develop" ]
workflow_dispatch:
jobs:
build:
name: Packge project and deploy to tomcat
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Update MongoDB in application.properties
env:
MONGODB_HOST: ${{ secrets.MONGODB_HOST }}
MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }}
run: |
sed -i "s/^spring.data.mongodb.host=.*$/spring.data.mongodb.host=$MONGODB_HOST/" src/main/resources/application.properties
sed -i "s/^spring.data.mongodb.database=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" src/main/resources/application.properties
- name: Build with Maven
run: mvn clean package -DskipTests
- name: Prepare deployment directory
run: mkdir -p deployment && cp target/*.war deployment/
- name: Copy WAR to Tomcat server
run: sudo cp deployment/*.war /opt/tomcat/webapps/marketplace-server.war
- name: Restart Tomcat server
run: |
sudo systemctl stop tomcat
sudo systemctl start tomcat