Add Github Workflow for continuous deployment (#93) #1
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 Frontend | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: Ubuntu-latest | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
- name: Install SSH Agent | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_VCM }} | ||
- name: Copy new changes | ||
run: | | ||
Check failure on line 22 in .github/workflows/deploy.yml
|
||
ssh -o StrictHostKeyChecking=no ${{ secrets.VCM_HOST_USERNAME }}@${{ secrets.VCM_HOST_DNS }} 'rm -rf ${{ VCM_FRONTEND_DIR }}' | ||
scp -o StrictHostKeyChecking=no -r ./* ${{ secrets.VCM_HOST_USERNAME}}@${{ secrets.VCM_HOST_DNS }}:${{VCM_FROTEND_DIR}} | ||
- name: Build the changes and deploy | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.VCM_HOST_USERNAME }}@${{ secrets.VCM_HOST_DNS }} << EOF | ||
sudo cd ${{ VCM_FRONTEND_DIR }} | ||
sudo npm install | ||
sudo npm run build | ||
sudo rm -rf /var/www | ||
sudo cp -r dist/* /var/www/ | ||
sudo systemctl restart nginx | ||
EOF | ||