Skip to content

Merge pull request #6 from Recoupable-com/sweetmantech/myc-3158-readme #5

Merge pull request #6 from Recoupable-com/sweetmantech/myc-3158-readme

Merge pull request #6 from Recoupable-com/sweetmantech/myc-3158-readme #5

Workflow file for this run

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-Telegram-Bot
cd ~/Recoup-Telegram-Bot
# Initialize git repository if it doesn't exist
if [ ! -d .git ]; then
git init
git remote add origin https://github.com/Recoupable-com/Recoup-Telegram-Bot.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 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