Merge pull request #172 from Recoupable-com/sweetmantech/myc-3464-api… #807
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 DigitalOcean Droplet | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: "20" | |
| - name: Install pnpm | |
| run: npm install -g pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Debug Secrets | |
| run: | | |
| echo "DROPLET_IP is set: ${{ secrets.DROPLET_IP != '' }}" | |
| echo "DROPLET_USER is set: ${{ secrets.DROPLET_USER != '' }}" | |
| echo "DROPLET_PASSWORD is set: ${{ secrets.DROPLET_PASSWORD != '' }}" | |
| - name: Deploy to DigitalOcean Droplet | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.DROPLET_IP }} | |
| username: ${{ secrets.DROPLET_USER }} | |
| password: ${{ secrets.DROPLET_PASSWORD }} | |
| script: | | |
| echo "Connected to Droplet" | |
| # Create app directory if it doesn't exist | |
| mkdir -p ~/recoup-agent-apis | |
| cd ~/recoup-agent-apis | |
| # Initialize git repository if it doesn't exist | |
| if [ ! -d .git ]; then | |
| git init | |
| git remote add origin https://github.com/sweetmantech/Recoup-Agent-APIs.git | |
| fi | |
| # Fetch latest code and handle local changes | |
| git fetch --all | |
| git checkout -B ${{ github.ref_name }} origin/${{ github.ref_name }} | |
| git reset HEAD --hard | |
| git pull origin/${{ github.ref_name }} | |
| echo "Current branch:" | |
| git branch --show-current | |
| echo "Git status:" | |
| git status | |
| # Install bun globally if not already installed | |
| if ! command -v bun &> /dev/null; then | |
| echo "Installing bun globally..." | |
| sudo curl -fsSL https://bun.sh/install | sudo bash | |
| sudo ln -s ~/.bun/bin/bun /usr/local/bin/bun | |
| fi | |
| # Install pnpm if not already installed | |
| if ! command -v pnpm &> /dev/null; then | |
| echo "Installing pnpm globally..." | |
| npm install -g pnpm | |
| fi | |
| # Ensure correct Node.js version | |
| source ~/.nvm/nvm.sh | |
| nvm use 20 | |
| # Install dependencies | |
| pnpm install | |
| # Restart the application | |
| pm2 restart ecosystem.config.cjs --update-env |