-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e5af2a
commit dd5dbc2
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |
dd5dbc2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
observerx-docs – ./
observerx-docs.vercel.app
observerx-docs-git-main-samzhang.vercel.app
observerx-docs-samzhang.vercel.app
observerx.samzhangjy.com