ci: update deploy.yml to reset changes for package lock before pulling #26
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 to Linode | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| concurrency: | |
| group: deployment | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to server | |
| uses: appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: root | |
| password: ${{ secrets.SERVER_PASSWORD }} | |
| script: | | |
| set -euo pipefail | |
| trap 'rm -f ~/.git-credentials; git config --unset credential.helper || true' EXIT | |
| cd /var/www/monstar | |
| # Configure git credentials for pulling | |
| git config credential.helper store | |
| echo "https://${{ secrets.USERNAME }}:${{ secrets.PAT }}@github.com" > ~/.git-credentials | |
| # Discard local changes to package-lock.json | |
| git checkout -- frontend/package-lock.json || true | |
| # Pull latest changes | |
| git pull origin main | |
| # Install backend dependencies | |
| cd /var/www/monstar/backend | |
| npm install | |
| # Install frontend dependencies | |
| cd /var/www/monstar/frontend | |
| npm install --legacy-peer-deps | |
| # Stop the service | |
| sudo systemctl stop monstar.service | |
| # Build frontend | |
| cd /var/www/monstar/frontend | |
| ng build --configuration production | |
| # Start the service | |
| sudo systemctl start monstar.service | |
| # Check if service started successfully | |
| sleep 5 | |
| if systemctl is-active --quiet monstar.service; then | |
| echo "✅ Deployment successful - monstar.service is running" | |
| else | |
| echo "❌ Deployment failed - monstar.service failed to start" | |
| sudo systemctl status monstar.service | |
| sudo journalctl -u monstar.service --no-pager -n 50 | |
| exit 1 | |
| fi |