Skip to content

Commit

Permalink
Merge branch 'development' into Issue#9905_Disposal_cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
GSMgeeth authored Jan 1, 2025
2 parents d572bd0 + 47f6989 commit 5f9fc01
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 29 deletions.
36 changes: 23 additions & 13 deletions .github/workflows/coop_dev_ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: COOP-DEV Deployment Pipeline
name: COOP-DEV Build & Deployment Pipeline

on:
push:
Expand Down Expand Up @@ -27,6 +27,15 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
- name: Update JDBC Data Sources in persistence.xml
run: |
sed -i 's|<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/coop</jta-data-source>|' src/main/resources/META-INF/persistence.xml
sed -i 's|<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/coopaudit</jta-data-source>|' src/main/resources/META-INF/persistence.xml
- name: Verify JDBC Data Sources in persistence.xml
run: |
grep '<jta-data-source>' src/main/resources/META-INF/persistence.xml
- name: Build with Maven
run: mvn clean package -DskipTests

Expand Down Expand Up @@ -55,24 +64,25 @@ jobs:

- name: Deploy to Payara
env:
SERVER_IP: ${{ secrets.SERVER_IP }}
SERVER_USER: ${{ secrets.SERVER_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
PAYARA_ADMIN_PASS: ${{ secrets.PAYARA_ADMIN_PASS }}
SERVER_IP: ${{ secrets.DEV_SERVER_IP }}
SERVER_USER: ${{ secrets.DEV_SERVER_USER }}
SSH_PRIVATE_KEY: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
PAYARA_ADMIN_PASS: ${{ secrets.DEV_PAYARA_ADMIN_PASS }}
run: |
# Add SSH private key to the SSH agent
echo "$SSH_PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
# Variables
WAR_NAME="coop-dev.war"
WAR_NAME="coop.war"
WAR_DIR="/home/appuser/app/latest"
APP_NAME="coop-dev"
APP_NAME="coop"
SUBDOMAIN="dev"
# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
sudo mkdir -p $WAR_DIR
sudo chown -R appuser:appuser /home/appuser/app
sudo chown -R appuser:appuser /home/appuser/app/latest
sudo su - appuser
cd $WAR_DIR
Expand All @@ -99,7 +109,7 @@ jobs:
# Deploy the WAR using asadmin
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
sudo su - appuser
echo 'AS_ADMIN_PASSWORD=${{ secrets.PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
echo 'AS_ADMIN_PASSWORD=${{ secrets.DEV_PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt undeploy $APP_NAME || true
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt deploy --force=true --contextroot $APP_NAME $WAR_DIR/$WAR_NAME
rm /tmp/payara-admin-pass.txt
Expand All @@ -108,8 +118,8 @@ jobs:
# Validate if the application is running
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
sudo su - appuser
echo 'AS_ADMIN_PASSWORD=${{ secrets.PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q 'coop-dev'; then
echo 'AS_ADMIN_PASSWORD=${{ secrets.DEV_PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q '$APP_NAME'; then
echo 'Application is running.'
else
echo 'Application failed to start.'
Expand All @@ -119,12 +129,12 @@ jobs:
# Check if the application is reachable
for i in {1..5}; do
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://coop-dev.carecode.org/coop-dev/faces/index1.xhtml)
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/faces/index1.xhtml)
if [ "$RESPONSE_CODE" == "200" ]; then
echo "Application is reachable and healthy."
break
elif [ "$i" == "5" ]; then
echo "Application is not reachable or unhealthy at https://coop-dev.carecode.org/coop-dev (HTTP $RESPONSE_CODE)"
echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
break
fi
sleep 10
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/coop_prod_ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: COOP-PROD Deployment Pipeline
name: COOP-PROD Build & Deployment Pipeline

on:
push:
branches:
- coop-prod
# workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'

steps:
- name: Checkout Code
Expand All @@ -29,6 +27,15 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
- name: Update JDBC Data Sources in persistence.xml
run: |
sed -i 's|<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/coop</jta-data-source>|' src/main/resources/META-INF/persistence.xml
sed -i 's|<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/coopaudit</jta-data-source>|' src/main/resources/META-INF/persistence.xml
- name: Verify JDBC Data Sources in persistence.xml
run: |
grep '<jta-data-source>' src/main/resources/META-INF/persistence.xml
- name: Build with Maven
run: mvn clean package -DskipTests

Expand All @@ -44,7 +51,6 @@ jobs:
deploy:
needs: build
runs-on: ubuntu-latest
# if: github.event_name == 'workflow_dispatch'

steps:
- name: Checkout Code
Expand Down Expand Up @@ -73,11 +79,12 @@ jobs:
WAR_NAME="coop.war"
WAR_DIR="/home/appuser/app/latest"
APP_NAME="coop"
SUBDOMAIN="coop"
# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
sudo mkdir -p $WAR_DIR
sudo chown -R appuser:appuser /home/appuser/app
sudo chown -R appuser:appuser /home/appuser/app/latest
sudo su - appuser
cd $WAR_DIR
Expand Down Expand Up @@ -124,12 +131,12 @@ jobs:
# Check if the application is reachable
for i in {1..5}; do
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$APP_NAME.carecode.org/$APP_NAME/faces/index1.xhtml)
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/faces/index1.xhtml)
if [ "$RESPONSE_CODE" == "200" ]; then
echo "Application is reachable and healthy."
break
elif [ "$i" == "5" ]; then
echo "Application is not reachable or unhealthy at https://$APP_NAME.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
break
fi
sleep 10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/custom_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- warning
- debug
tags:
description: 'Tags of the workflow'
description: 'Tags for the workflow'
required: true
type: string

Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/rh_dev_ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: RH-DEV Deployment Pipeline
name: RH-DEV Build & Deployment Pipeline

on:
push:
Expand Down Expand Up @@ -27,6 +27,15 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
- name: Update JDBC Data Sources in persistence.xml
run: |
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
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
- name: Verify JDBC Data Sources in persistence.xml
run: |
grep '<jta-data-source>' src/main/resources/META-INF/persistence.xml
- name: Build with Maven
run: mvn clean package -DskipTests

Expand Down Expand Up @@ -65,14 +74,15 @@ jobs:
chmod 600 private_key.pem
# Variables
WAR_NAME="dev.war"
WAR_NAME="rh.war"
WAR_DIR="/home/appuser/app/latest"
APP_NAME="dev"
APP_NAME="rh"
SUBDOMAIN="dev"
# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
sudo mkdir -p $WAR_DIR
sudo chown -R appuser:appuser /home/appuser/app
sudo chown -R appuser:appuser /home/appuser/app/latest
sudo su - appuser
cd $WAR_DIR
Expand Down Expand Up @@ -119,12 +129,12 @@ jobs:
# Check if the application is reachable
for i in {1..5}; do
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://'$APP_NAME'.carecode.org/'$APP_NAME'/faces/index1.xhtml)
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/faces/index1.xhtml)
if [ "$RESPONSE_CODE" == "200" ]; then
echo "Application is reachable and healthy."
break
elif [ "$i" == "5" ]; then
echo "Application is not reachable or unhealthy at https://'$APP_NAME'.carecode.org/'$APP_NAME' (HTTP $RESPONSE_CODE)"
echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
break
fi
sleep 10
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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">
<persistence-unit name="hmisPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/ruhunu</jta-data-source>
<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
Expand All @@ -13,7 +13,7 @@
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>jdbc/ruhunuaudit</jta-data-source>
<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
Expand Down

0 comments on commit 5f9fc01

Please sign in to comment.