Update .env.production #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy build to AzureVM | |
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 | |
- 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 | |
- name: Copy build files to AzureVM | |
run: | | |
scp -i /home/runner/.ssh/id_rsa -r build/* ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/home/azureuser/server/healthcare_static_build/build/ | |
- name: Deploy to VM | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
script: | | |
# Create the script file with Docker commands | |
echo "#!/bin/bash" > docker_commands.sh | |
echo "docker-compose down" >> docker_commands.sh | |
echo "docker-compose build" >> docker_commands.sh | |
echo "docker-compose up -d" >> docker_commands.sh | |
echo "docker image prune -f" >> docker_commands.sh | |
echo "docker volume prune -f" >> docker_commands.sh | |
chmod +x docker_commands.sh | |
# execute the script after invoking following command | |
# it will continue to run on server !! | |
./docker_commands.sh & |