name: CI/CD Pipeline on: push: branches: - main - develop jobs: deploy_testing: if: github.ref == 'refs/heads/develop' runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3 - name: Deploy to Testing Server uses: appleboy/ssh-action@master with: host: ${{ secrets.TEST_SERVER_IP }} username: ${{ secrets.SERVER_USER }} key: ${{ secrets.SERVER_SSH_KEY }} script: | echo "✅ Connected to Testing Server" cd /home/${{ secrets.SERVER_USER }}/app docker stop myapp || true docker rm myapp || true docker build -t myapp:latest . docker run -d --name myapp -p 3000:3000 myapp:latest deploy_production: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3 - name: Deploy to Production Server uses: appleboy/ssh-action@master with: host: ${{ secrets.PROD_SERVER_IP }} username: ${{ secrets.SERVER_USER }} key: ${{ secrets.SERVER_SSH_KEY }} script: | echo "✅ Connected to Production Server" cd /home/${{ secrets.SERVER_USER }}/app docker stop myapp || true docker rm myapp || true docker build -t myapp:latest . docker run -d --name myapp -p 3000:3000 myapp:latest