Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coop test #10442

Merged
merged 29 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3933939
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
66567c4
update workflow file of coop-test application
ChinthakaPrasad Feb 6, 2025
eb41264
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
dc094c2
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
78518d3
Coop test ci cd workflow (#10434)
ChinthakaPrasad Feb 6, 2025
27d3b10
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
22cc485
Merge branch 'coop-test' into coop-test-ci-cd-workflow
ChinthakaPrasad Feb 6, 2025
0f2bd7e
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
5270ee1
Merge branch 'coop-test-ci-cd-workflow' of https://github.com/hmislk/…
ChinthakaPrasad Feb 6, 2025
2cd89ce
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
07e5d53
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
f7972c4
Coop test ci cd workflow (#10438)
ChinthakaPrasad Feb 6, 2025
3783bae
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
c4f035d
Merge branch 'coop-test' into coop-test-ci-cd-workflow
ChinthakaPrasad Feb 6, 2025
c1f29eb
Coop test ci cd workflow (#10439)
ChinthakaPrasad Feb 6, 2025
cd5e099
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
f8f8885
Merge branch 'coop-test-ci-cd-workflow' of https://github.com/hmislk/…
ChinthakaPrasad Feb 6, 2025
b10e35c
Merge branch 'coop-test' into coop-test-ci-cd-workflow
ChinthakaPrasad Feb 6, 2025
38b3aa4
Coop test ci cd workflow (#10440)
ChinthakaPrasad Feb 6, 2025
1afa2d6
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
803214a
Merge branch 'coop-test-ci-cd-workflow' of https://github.com/hmislk/…
ChinthakaPrasad Feb 6, 2025
8814dcf
Coop test ci cd workflow (#10441)
ChinthakaPrasad Feb 6, 2025
323cd3f
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
450c3a8
Merge branch 'coop-test' of https://github.com/hmislk/hmis.git into c…
ChinthakaPrasad Feb 6, 2025
c6c44df
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
eaf08e7
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
8c8d900
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
007578b
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Feb 6, 2025
d8911b9
Merge branch 'development' into coop-test
GSMgeeth Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .github/workflows/coop_test_ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Coop Test Environment(QA) CI-CD Workflow

on:
push:
branches:
- coop-test

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Cache Maven Packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
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

- name: Archive Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: target/*.war
overwrite: true

# - name: Run Tests
# run: mvn test

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./

- name: Deploy to Payara
env:
SERVER_IP: ${{ secrets.QA_SERVER_IP }}
SERVER_USER: ${{ secrets.QA_SERVER_USER }}
SSH_PRIVATE_KEY: ${{ secrets.QA_SSH_PRIVATE_KEY }}
PAYARA_ADMIN_PASS: ${{ secrets.QA_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-test.war"
WAR_DIR="/home/appuser/app/latest"
APP_NAME="coop-test"
SUBDOMAIN="qa"
CONTEXT_PATH="coop-test"

# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
mkdir -p $WAR_DIR
chown -R appuser:appuser $WAR_DIR
cd $WAR_DIR

# Remove old backup if it exists
if [ -f $WAR_NAME.old ]; then
rm $WAR_NAME.old
fi

# If the current WAR file exists, back it up
if [ -f $WAR_NAME ]; then
mv $WAR_NAME $WAR_NAME.old
fi
"

# Copy new WAR file to the server
rsync -aL --progress -e "ssh -i private_key.pem" ./*.war $SERVER_USER@$SERVER_IP:$WAR_DIR/$WAR_NAME

# Set the WAR file permission
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
chown appuser:appuser $WAR_DIR/$WAR_NAME
"

# Deploy the WAR using asadmin
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=$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 $CONTEXT_PATH $WAR_DIR/$WAR_NAME
rm /tmp/payara-admin-pass.txt
"

# Validate if the application is running
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=$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.'
fi
rm /tmp/payara-admin-pass.txt
"

# Check if the application is reachable
for i in {1..5}; do
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$CONTEXT_PATH/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://$SUBDOMAIN.carecode.org/$CONTEXT_PATH (HTTP $RESPONSE_CODE)"
break
fi
sleep 10
done

# Cleanup
rm -f private_key.pem