Skip to content

Merge pull request #543 from ertush/hotfix #352

Merge pull request #543 from ertush/hotfix

Merge pull request #543 from ertush/hotfix #352

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
env:
NEXT_PUBLIC_API_URL: 'https://api.kmhfr.health.go.ke/api'
TOKEN_URL: 'https://api.kmhfr.health.go.ke/o/token'
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
GRANT_TYPE: 'password'
NEXT_PUBLIC_CLIENT_USERNAME: 'public@mfltest.slade360.co.ke'
CLIENT_PASSWORD: ${{secrets.CLIENT_PASSWORD}}
NEXT_PUBLIC_CLIENT_PUBLIC_ID: ${{secrets.NEXT_PUBLIC_CLIENT_PUBLIC_ID}}
CLIENT_PUBLIC_SECRET: ${{secrets.CLIENT_PUBLIC_SECRET}}
NEXT_PUBLIC_PUBLIC_TOKEN_URL: 'https://api.kmhfr.health.go.ke/o/token/'
NEXT_PUBLIC_FACILITY_EXPORT_URL: 'https://api.kmhfr.health.go.ke/api/facilities/material/'
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['18.x']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Build Dependencies
run : yarn global add pm2; yarn global add pnpm
- name: Deploy to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_KEY }}
script: |
set -e
cd /var/www/kmhfr
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
if ! [[ -d './.git' ]]; then git init; fi
if ! [[ `git remote -v | awk '{print $1}' | head -n 1` =~ 'origin' ]]; then git remote add origin ${{ github.server_url }}${{ github.username }}/${{ github.repository }}.git; fi
git stash;
git pull origin main;
echo `pwd`;
- name: Install dependencies and build app
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: |
node -e """
const {exec} = require('node:child-process');
exec('ls . && pwd', (stdout) => {
console.log(`stdout: ${stdout}`)
})
"""
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run build
- run: pnpm dlx pm2 startOrRestart /var/www/kmhfr/ecosystem.config.js --env local
- run: pnpm dlx pm2 save
# test:
# timeout-minutes: 60
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# - name: Install build dependecies
# run: yarn global add pnpm && yarn global add playwright
# - name: Install Playwright Browsers
# run: pnpm exec playwright install --with-deps
# - name: Install App dependencies
# run: pnpm install
# - name: Run Playwright tests
# run: pnpm run test
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30