Change git branch from 'main' to 'master' in deploy.yml #2
This file contains hidden or 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 FieldTrack Backend | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.DO_SSH_KEY }}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| ssh-keyscan -H ${{ secrets.DO_HOST }} >> ~/.ssh/known_hosts | |
| - name: Deploy over SSH | |
| run: | | |
| ssh ${{ secrets.DO_USER }}@${{ secrets.DO_HOST }} << 'EOF' | |
| set -e | |
| cd ~/FieldTrack-2.0/backend | |
| echo "Pulling latest code..." | |
| git pull origin master | |
| echo "Stopping old container..." | |
| docker stop fieldtrack || true | |
| docker rm fieldtrack || true | |
| echo "Building new image..." | |
| docker build -t fieldtrack:latest . | |
| echo "Starting new container..." | |
| docker run -d \ | |
| --name fieldtrack \ | |
| --restart unless-stopped \ | |
| -p 3000:3000 \ | |
| --env-file .env \ | |
| fieldtrack:latest | |
| echo "Waiting for health..." | |
| sleep 8 | |
| echo "Checking health..." | |
| curl -f http://localhost:3000/health | |
| echo "Deploy successful." | |
| EOF |