Skip to content

Workflow file for this run

name: Deploy to Vultr
on:
push:
branches:
- main
jobs:

Check failure on line 8 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy.yml

Invalid workflow file

You have an error in your yaml syntax on line 8
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.VULTR_SSH_PRIVATE_KEY }}
- name: Verify SSH connection
run: ssh -o StrictHostKeyChecking=no root@${{ secrets.VULTR_IP }} "echo 'SSH connection successful'"
# Add a step to install dependencies and build the project
- name: Install dependencies and build project
run: |
npm install
npm run build
# Git clone instead of SCP
- name: Deploy code to Vultr
run: ssh -o StrictHostKeyChecking=no root@${{ secrets.VULTR_IP }} "cd /root/deploy/happiness-backend && git pull || git clone https://github.com/YOUR_REPO/happiness-backend.git /root/deploy/happiness-backend"
- name: Restart Docker container
run: |
ssh -o StrictHostKeyChecking=no root@${{ secrets.VULTR_IP }} "
CONTAINER_ID=\$(docker ps -q -f name=happiness-backend);
if [ ! -z \"\$CONTAINER_ID\" ]; then
docker container stop \$CONTAINER_ID;
fi;
CONTAINER_ID=\$(docker ps -a -q -f name=happiness-backend);
if [ ! -z \"\$CONTAINER_ID\" ]; then
docker container rm \$CONTAINER_ID;
fi;
docker container run -d -p 80:3010 --name happiness-backend /root/deploy/happiness-backend
"