Skip to content

Commit f29735c

Browse files
committed
adding deployement file to generate jar in github and deploy it on staging.
1 parent 191729f commit f29735c

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build and Deploy to Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- sms-properties-changes
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Step 1: Check out the code
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
# Step 2: Set up Java
18+
- name: Set up JDK
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '8' # Specify your Java version
22+
23+
# Step 3: Build the JAR
24+
- name: Build with Maven
25+
run: mvn clean intsall
26+
27+
# Step 4 : shutdown tomcat if it is started
28+
- name: Shutdown Tomcat if it is up
29+
uses: appleboy/ssh-action@v0.1.6
30+
with:
31+
host: ${{ secrets.STAGING_HOST }}
32+
username: ${{ secrets.STAGING_USER }}
33+
key: ${{ secrets.STAGING_KEY }}
34+
script: |
35+
if pgrep -f "org.apache.catalina.startup.Bootstrap" > /dev/null; then
36+
echo "Tomcat is running. Shutting it down..."
37+
sh /usr/local/tomcat/apache-tomcat-7.0.108/bin/shutdown.sh
38+
else
39+
echo "Tomcat is not running."
40+
fi
41+
42+
# Step 5: Deploy to Staging Server
43+
- name: Deploy to Staging
44+
uses: appleboy/scp-action@v0.1.4
45+
with:
46+
host: ${{ secrets.STAGING_HOST }}
47+
username: ${{ secrets.STAGING_USER }}
48+
key: ${{ secrets.STAGING_KEY }}
49+
source: "NMSReportingSuite/target/*.war"
50+
target: /usr/local/tomcat/apache-tomcat-7.0.108/webapps
51+
52+
# Step 6: Restart Application (if needed)
53+
- name: Restart tomcat
54+
uses: appleboy/ssh-action@v0.1.6
55+
with:
56+
host: ${{ secrets.STAGING_HOST }}
57+
username: ${{ secrets.STAGING_USER }}
58+
key: ${{ secrets.STAGING_KEY }}
59+
script: |
60+
if ! pgrep -f "org.apache.catalina.startup.Bootstrap" > /dev/null; then
61+
echo "Tomcat is not running. Starting it up..."
62+
sh /usr/local/tomcat/apache-tomcat-7.0.108/bin/startup.sh
63+
else
64+
echo "Tomcat is already running."
65+
fi
66+

0 commit comments

Comments
 (0)