Skip to content

Commit cdfb89f

Browse files
authored
Merge branch 'development' into issue#9931_Expiry_Item_Improvement
2 parents 135d5a7 + 7adb794 commit cdfb89f

File tree

4 files changed

+147
-3
lines changed

4 files changed

+147
-3
lines changed

.github/workflows/rh_dev_ci_cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: RH-DEV Build & Deployment Pipeline
33
on:
44
push:
55
branches:
6-
- dev-ci-cd-setup
6+
- ruhunu-dev
77

88
jobs:
99
build:

.github/workflows/rh_prod_ci_cd.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: RH-PROD Build & Deployment Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- ruhunu-prod
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v3
18+
with:
19+
distribution: 'temurin'
20+
java-version: '11'
21+
22+
- name: Cache Maven Packages
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/.m2
26+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
27+
restore-keys: |
28+
${{ runner.os }}-maven-
29+
30+
- name: Update JDBC Data Sources in persistence.xml
31+
run: |
32+
sed -i 's|<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/ruhunu</jta-data-source>|' src/main/resources/META-INF/persistence.xml
33+
sed -i 's|<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/ruhunuAudit</jta-data-source>|' src/main/resources/META-INF/persistence.xml
34+
35+
- name: Verify JDBC Data Sources in persistence.xml
36+
run: |
37+
grep '<jta-data-source>' src/main/resources/META-INF/persistence.xml
38+
39+
- name: Build with Maven
40+
run: mvn clean package -DskipTests
41+
42+
- name: Archive Build Artifacts
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: build-artifacts
46+
path: target/*.war
47+
48+
# - name: Run Tests
49+
# run: mvn test
50+
51+
deploy:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
55+
steps:
56+
- name: Checkout Code
57+
uses: actions/checkout@v3
58+
59+
- name: Download Build Artifact
60+
uses: actions/download-artifact@v3
61+
with:
62+
name: build-artifacts
63+
path: ./
64+
65+
- name: Deploy to Payara
66+
env:
67+
SERVER_IP: ${{ secrets.RUHUNU_PROD_SERVER_IP }}
68+
SERVER_USER: ${{ secrets.RUHUNU_PROD_SERVER_USER }}
69+
SSH_PRIVATE_KEY: ${{ secrets.RUHUNU_PROD_SSH_PRIVATE_KEY }}
70+
PAYARA_ADMIN_PASS: ${{ secrets.RUHUNU_PROD_PAYARA_ADMIN_PASS }}
71+
run: |
72+
# Add SSH private key to the SSH agent
73+
echo "$SSH_PRIVATE_KEY" > private_key.pem
74+
chmod 600 private_key.pem
75+
76+
# Variables
77+
WAR_NAME="rh.war"
78+
WAR_DIR="/home/appuser/app/latest"
79+
APP_NAME="rh"
80+
SUBDOMAIN="rh"
81+
82+
# Ensure deployment directory exists
83+
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
84+
sudo mkdir -p $WAR_DIR
85+
sudo chown -R appuser:appuser /home/appuser/app/latest
86+
sudo su - appuser
87+
cd $WAR_DIR
88+
89+
# Remove old backup if it exists
90+
if [ -f $WAR_NAME.old ]; then
91+
rm $WAR_NAME.old
92+
fi
93+
94+
# If the current WAR file exists, back it up
95+
if [ -f $WAR_NAME ]; then
96+
mv $WAR_NAME $WAR_NAME.old
97+
fi
98+
"
99+
100+
# Copy new WAR file to the server
101+
rsync -aL --progress -e "ssh -i private_key.pem" ./*.war $SERVER_USER@$SERVER_IP:/tmp/$WAR_NAME
102+
103+
# Move the file to /home/appuser/app/latest/ and set permissions
104+
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
105+
sudo mv /tmp/$WAR_NAME $WAR_DIR/
106+
sudo chown appuser:appuser $WAR_DIR/$WAR_NAME
107+
"
108+
109+
# Deploy the WAR using asadmin
110+
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
111+
sudo su - appuser
112+
echo 'AS_ADMIN_PASSWORD=${{ secrets.DEV_PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
113+
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt undeploy $APP_NAME || true
114+
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt deploy --force=true --contextroot $APP_NAME $WAR_DIR/$WAR_NAME
115+
rm /tmp/payara-admin-pass.txt
116+
"
117+
118+
# Validate if the application is running
119+
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
120+
sudo su - appuser
121+
echo 'AS_ADMIN_PASSWORD=${{ secrets.DEV_PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
122+
if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q '$APP_NAME'; then
123+
echo 'Application is running.'
124+
else
125+
echo 'Application failed to start.'
126+
fi
127+
rm /tmp/payara-admin-pass.txt
128+
"
129+
130+
# Check if the application is reachable
131+
for i in {1..5}; do
132+
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/faces/index1.xhtml)
133+
if [ "$RESPONSE_CODE" == "200" ]; then
134+
echo "Application is reachable and healthy."
135+
break
136+
elif [ "$i" == "5" ]; then
137+
echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
138+
break
139+
fi
140+
sleep 10
141+
done
142+
143+
# Cleanup
144+
rm -f private_key.pem

src/main/resources/META-INF/persistence.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
33
<persistence-unit name="hmisPU" transaction-type="JTA">
4-
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
5-
4+
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
65
<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>
76
<exclude-unlisted-classes>false</exclude-unlisted-classes>
87
<properties>

src/main/webapp/reports/inventoryReports/expiry_item.xhtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331

332332
</p:dataTable>
333333

334+
334335
</div>
335336

336337
</p:panel>

0 commit comments

Comments
 (0)