-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (57 loc) · 1.98 KB
/
NMSReportingSuite-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build and Deploy to Staging
on:
push:
branches:
- deployment
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the code
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Set up Java
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '8'
# Step 3: Build the JAR
- name: Build with Maven
run: mvn clean install
# Step 4: Shutdown Tomcat if it is started
- name: Shutdown Tomcat if it is up
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USER }}
key: ${{ secrets.STAGING_KEY }}
script: |
if pgrep -f "org.apache.catalina.startup.Bootstrap" > /dev/null; then
echo "Tomcat is running. Shutting it down..."
sh /usr/local/tomcat/apache-tomcat-7.0.108/bin/shutdown.sh
else
echo "Tomcat is not running."
fi
# Step 5: Deploy to Staging Server
- name: Deploy to Staging
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USER }}
key: ${{ secrets.STAGING_KEY }}
source: "NMSReportingSuite/target/*.war"
target: /usr/local/tomcat/apache-tomcat-7.0.108/webapps
# Step 6: Restart Application (if needed)
- name: Restart Tomcat
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USER }}
key: ${{ secrets.STAGING_KEY }}
script: |
if ! pgrep -f "org.apache.catalina.startup.Bootstrap" > /dev/null; then
echo "Tomcat is not running. Starting it up..."
sh /usr/local/tomcat/apache-tomcat-7.0.108/bin/startup.sh
else
echo "Tomcat is already running."
fi