Skip to content

Commit 7070ec8

Browse files
Merge pull request #16 from hmislk/main
update drawer prod from main
2 parents aafae75 + d074c47 commit 7070ec8

3 files changed

Lines changed: 179 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: PR Validator
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened ]
6+
branches:
7+
- main
8+
- '*-prod'
9+
10+
jobs:
11+
validate-jdbc-data-sources:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
18+
- name: Verify JDBC Data Sources in persistence.xml
19+
run: |
20+
grep -q '<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>' src/main/resources/META-INF/persistence.xml
21+
22+
validate-compilation:
23+
needs: validate-jdbc-data-sources
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout Code
28+
uses: actions/checkout@v4
29+
30+
- name: Set up JDK 8
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: 'temurin'
34+
java-version: '8'
35+
36+
- name: Compile with Maven
37+
run: mvn clean compile
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Drawer Prod Build & Deployment Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- drawer-prod
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up JDK 8
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: 'temurin'
20+
java-version: '8'
21+
22+
- name: Cache Maven Packages
23+
uses: actions/cache@v4
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/rhdrawer</jta-data-source>|' src/main/resources/META-INF/persistence.xml
33+
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@v4
44+
with:
45+
name: build-artifacts
46+
path: target/*.war
47+
overwrite: true
48+
49+
# - name: Run Tests
50+
# run: mvn test
51+
52+
# deploy:
53+
# needs: build
54+
# runs-on: ubuntu-latest
55+
56+
# steps:
57+
# - name: Checkout Code
58+
# uses: actions/checkout@v4
59+
60+
# - name: Download Build Artifact
61+
# uses: actions/download-artifact@v4
62+
# with:
63+
# name: build-artifacts
64+
# path: ./
65+
66+
# - name: Deploy to Payara
67+
# env:
68+
# SERVER_IP: ${{ secrets.RUHUNU_DRAWER_IP }}
69+
# SERVER_USER: ${{ secrets.RUHUNU_DRAWER_USER }}
70+
# SSH_PRIVATE_KEY: ${{ secrets.RUHUNU_DRAWER_SSH_PRIVATE_KEY }}
71+
# PAYARA_ADMIN_PASS: ${{ secrets.RUHUNU_DRAWER_PAYARA_ADMIN_PASSWORD }}
72+
# run: |
73+
# # Add SSH private key to the SSH agent
74+
# echo "$SSH_PRIVATE_KEY" > private_key.pem
75+
# chmod 600 private_key.pem
76+
77+
# # Variables
78+
# WAR_NAME="drawer.war"
79+
# WAR_DIR="/home/appuser/app/latest"
80+
# APP_NAME="drawer"
81+
# SUBDOMAIN="rhdrawer"
82+
83+
# # Ensure deployment directory exists
84+
# ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
85+
# mkdir -p $WAR_DIR
86+
# chown -R appuser:appuser $WAR_DIR
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:$WAR_DIR/$WAR_NAME
102+
103+
# # Set the WAR file permission
104+
# ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
105+
# chown appuser:appuser $WAR_DIR/$WAR_NAME
106+
# "
107+
108+
# # Deploy the WAR using asadmin
109+
# ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
110+
# echo 'AS_ADMIN_PASSWORD=$PAYARA_ADMIN_PASS' > /tmp/payara-admin-pass.txt
111+
# /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt undeploy $APP_NAME || true
112+
# /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt deploy --force=true --contextroot $APP_NAME $WAR_DIR/$WAR_NAME
113+
# rm /tmp/payara-admin-pass.txt
114+
# "
115+
116+
# # Validate if the application is running
117+
# ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
118+
# echo 'AS_ADMIN_PASSWORD=$PAYARA_ADMIN_PASS' > /tmp/payara-admin-pass.txt
119+
# if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q '$APP_NAME'; then
120+
# echo 'Application is running.'
121+
# else
122+
# echo 'Application failed to start.'
123+
# fi
124+
# rm /tmp/payara-admin-pass.txt
125+
# "
126+
127+
# # Check if the application is reachable
128+
# for i in {1..5}; do
129+
# RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/)
130+
# if [ "$RESPONSE_CODE" == "200" ]; then
131+
# echo "Application is reachable and healthy."
132+
# break
133+
# elif [ "$i" == "5" ]; then
134+
# echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
135+
# break
136+
# fi
137+
# sleep 10
138+
# done
139+
140+
# # Cleanup
141+
# rm -f private_key.pem

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<persistence version="2.2" xmlns="http://xmlns.jcp.org/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="pu" transaction-type="JTA">
44
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
5-
<jta-data-source>jdbc/drawer</jta-data-source>
5+
<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>
66
<exclude-unlisted-classes>false</exclude-unlisted-classes>
77
<properties>
88
<!-- Logging Configuration (Minimal to avoid performance overhead) -->

0 commit comments

Comments
 (0)