Skip to content

updated deploy workflow and README file #1

updated deploy workflow and README file

updated deploy workflow and README file #1

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
# create .env.production or create if not present in folder!!!
- name: Overwrite or Create .env.production
run: echo "REACT_APP_API_URL=http://${{ secrets.HOST }}/api/v1/healthcare" > .env.production
- name: Build the React app
run: |
CI=false
npm run build
- name: Create SSH key file
run: |
mkdir -p /home/runner/.ssh
echo "${{ secrets.KEY }}" > /home/runner/.ssh/id_rsa
chmod 600 /home/runner/.ssh/id_rsa
- name: Configure SSH
run: |
echo "Host ${{ secrets.HOST }}" > /home/runner/.ssh/config
echo " StrictHostKeyChecking no" >> /home/runner/.ssh/config
# create static_healthcare if not exists
- name: Ensure static_healthcare directory exists
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
mkdir -p /home/azureuser/server/static_healthcare
- name: Copy build files to server
run: |
scp -i /home/runner/.ssh/id_rsa -r build/* ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/home/azureuser/server/static_healthcare/
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd /home/azureuser/server/
# start nginx with new build files
sudo docker rm -f nginx
sudo docker-compose up -d
sudo docker exec nginx nginx -s reload