Skip to content

KenyaEMR CI

KenyaEMR CI #655

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: Execute Development Build Script
run: |
chmod +x ./dev-build.sh
./dev-build.sh
- 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 }}
key: ${{ secrets.CICD_SECRET }}
port: ${{ secrets.PORT }}
script: |
cd /apps/githubworkflows/OpenMrs3.0_assets &&
tar -xzf frontend-${{ github.sha }}.tar.gz &&
sudo mv /var/lib/OpenMRS/frontend /var/lib/OpenMRS/frontend_old &&
sudo mv frontend /var/lib/OpenMRS/ &&
sudo rm -rf /var/lib/OpenMRS/frontend_old
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