Skip to content

Fix CI

Fix CI #41

Workflow file for this run

name: Build & Deploy
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
set -e
APP_DIR=~/gas-oracle
REPO_URL=git@github.com:kaonone/gas-oracle.git
# Clone or pull repository
if [ -d "$APP_DIR" ]; then
cd $APP_DIR
git fetch origin master
git reset --hard origin/master
else
git clone $REPO_URL $APP_DIR
cd $APP_DIR
fi
# Install dependencies
npm ci
# Create .env file
cat > .env << EOF
JSON_RPC_URL_1=${{ secrets.JSON_RPC_URL_1 }}
JSON_RPC_URL_56=${{ secrets.JSON_RPC_URL_56 }}
JSON_RPC_URL_42161=${{ secrets.JSON_RPC_URL_42161 }}
EOF
# Build the project
npm run build
# Install PM2 globally if not installed
command -v pm2 >/dev/null 2>&1 || npm install -g pm2
# Start or restart the application
pm2 startOrRestart ecosystem.config.js --env production
# Save PM2 process list for auto-restart on reboot
pm2 save