Build and Deploy Marketplace-Service on branch feature/MARP-277-Sonar-forSpringBoot by nqhoan-axonivy #5
Workflow file for this run
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: 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: 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 | |
env: | |
TOMCAT_USER: ${{ secrets.TOMCAT_USER }} | |
TOMCAT_PASSWORD: ${{ secrets.TOMCAT_PASSWORD }} | |
TOMCAT_HOST: ${{ secrets.TOMCAT_HOST }} | |
REMOTE_PATH: ${{ secrets.REMOTE_PATH }} | |
run: | | |
scp -o StrictHostKeyChecking=no deployment/*.war $TOMCAT_USER@$TOMCAT_HOST:$REMOTE_PATH/marketplace-server.war | |
- name: Restart Tomcat server | |
env: | |
TOMCAT_USER: ${{ secrets.TOMCAT_USER }} | |
TOMCAT_PASSWORD: ${{ secrets.TOMCAT_PASSWORD }} | |
TOMCAT_HOST: ${{ secrets.TOMCAT_HOST }} | |
run: | | |
ssh -o StrictHostKeyChecking=no $TOMCAT_USER@$TOMCAT_HOST << EOF | |
systemctl stop tomcat | |
systemctl start tomcat | |
EOF |