Skip to content

Update main.yml

Update main.yml #8

Workflow file for this run

name: Deploy to Instance
env:
REPO_NAME: ${{ github.event.repository.name }}
REPO_URL: ${{ github.event.repository.url }}
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Connect to AWS Lightsail, extract file and delete the file
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST_IP }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
passphrase: ""
port: 22
script: |
if [ -d /home/ubuntu/Wheelsdrive-CSMS ]; then
cd /home/ubuntu/Wheelsdrive-CSMS && git pull
else
git clone https://github.com/Pr3c10us/Wheelsdrive-CSMS.git /home/ubuntu/Wheelsdrive-CSMS2
fi
cd /home/ubuntu/Wheelsdrive-CSMS/Backend/Api && sudo npm install && if sudo npm stop; then
# If command1 succeeds
echo "Command 1 succeeded"
# Run another command
sudo npm start
else
# If command1 fails
echo "Command 1 failed"
# Run a different command
sudo npm start
cd /home/ubuntu/Wheelsdrive-CSMS/Backend/WebSocket && sudo npm install && if sudo npm stop; then
# If command1 succeeds
echo "Command 1 succeeded"
# Run another command
sudo npm start
else
# If command1 fails
echo "Command 1 failed"
# Run a different command
sudo npm start