Skip to content

Commit

Permalink
chore: added ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
samzhangjy committed Aug 27, 2023
1 parent 6e5af2a commit dd5dbc2
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Deploy to SSH server on push
run-name: Deploy latest version of ObserverX to SSH server.
on: [push]
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- name: Run CI deploy script
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
password: ${{ secrets.DEPLOY_PASSWORD }}
port: ${{ secrets.DEPLOY_PORT }}
script: |
echo "[INFO] ObserverX server CI script running with PID $$"
last_ran_pid_path=~/projects/observerx-panel/last-pid.txt

if [[ -f "$last_ran_pid_path" ]]
then
last_ran_pid=$(cat $last_ran_pid_path)

if [[ ! -z $last_ran_pid ]]
then
sudo kill -9 $last_ran_pid
fi
echo "[INFO] Killed existing CI process $last_ran_pid"
fi

# empty file first
cat /dev/null > $last_ran_pid_path
echo "$$" >> $last_ran_pid_path

node_pid=$(sudo lsof -i :443 | grep node | awk '{print $2}')

if [ ! -z $node_pid ]
then
sudo kill -9 $node_pid
echo "[INFO] Killed existing node process $node_pid"
fi

old_version=$(pnpm list -g @observerx/panel-server | grep @observerx/panel-server | awk '{print $2}')

echo "[INFO] Installing latest packages..."
pnpm add -g @observerx/panel-server@latest

new_version=$(pnpm list -g @observerx/panel-server | grep @observerx/panel-server | awk '{print $2}')

echo "[INFO] Installed latest packages: $old_version -> $new_version"

echo "[INFO] Server started."
cd ~/projects/observerx-panel
until observerx-admin start; do
echo "Server crashed with exit code $?. Respawning.." >&2
sleep 10
done

1 comment on commit dd5dbc2

@vercel
Copy link

@vercel vercel bot commented on dd5dbc2 Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.