Skip to content

Update deployment_8500_spa.yml (#333) #92

Update deployment_8500_spa.yml (#333)

Update deployment_8500_spa.yml (#333) #92

name: KenyaEMR CI
on:
push:
branches:
- main
- feat/fixCI
release:
types: [published]
workflow_dispatch:
jobs:
build_and_deploy:
name: Build and Deploy
runs-on: ubuntu-latest
strategy:
matrix:
node: [18.x]
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Clean up previous build artifacts
run: rm -rf openmrs-config-kenyaemr frontend
- name: Build Kenya EMR 3.x assets
run: npx --legacy-peer-deps openmrs@next build --build-config ./configuration/dev-build-config.json --target ./frontend --page-title "KenyaEMR" --support-offline false
- name: Assemble assets
run: npx --legacy-peer-deps openmrs@next assemble --manifest --mode config --config ./configuration/dev-build-config.json --target ./frontend
- name: Copy and move required files
run: |
cp ./assets/kenyaemr-login-logo.png ./frontend
cp ./assets/kenyaemr-primary-logo.svg ./frontend
cp ./assets/favicon.ico ./frontend
cp ./configuration/dev-config.json ./frontend/config.json
cp -r configuration frontend
- name: Compress frontend folder
run: tar -czvf frontend-${{ github.sha }}.tar.gz frontend/
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: frontend-${{ github.sha }}.tar.gz
path: frontend-${{ github.sha }}.tar.gz
- name: Upload compressed frontend to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.CICD_HOST }}
username: ${{ secrets.CICD_USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.CICD_SECRET }}
source: frontend-${{ github.sha }}.tar.gz
target: /apps/githubworkflows/OpenMrs3.0_assets/
- name: Execute remote SSH commands
uses: appleboy/[email protected]
with:
host: ${{ secrets.CICD_HOST }}
username: ${{ secrets.CICD_USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.CICD_SECRET }}
script: |
set -e
cd /apps/githubworkflows/OpenMrs3.0_assets &&
tar -xzf frontend-${{ github.sha }}.tar.gz &&
sudo mv /var/lib/OpenMRS/frontend /var/lib/OpenMRS/frontend_old &&
mv frontend /var/lib/OpenMRS/ &&
sudo rm -rf /var/lib/OpenMRS/frontend_old /var/lib/OpenMRS/configuration /var/lib/OpenMRS/configuration_checksums/ &&
sudo mv /var/lib/OpenMRS/frontend/configuration /var/lib/OpenMRS/ && sudo service tomcat9 restart
release:
runs-on: ubuntu-latest
needs: build_and_deploy
if: github.event_name == 'release'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- name: Run production build script
run: |
chmod +x ./prod-build.sh
./prod-build.sh
- name: Compress frontend folder for release
run: tar -czvf frontend-release-${{ github.sha }}.tar.gz frontend/
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
name: frontend-release-${{ github.sha }}.tar.gz
path: frontend-release-${{ github.sha }}.tar.gz