Skip to content

Commit

Permalink
Merge pull request #51 from serhatozdursun/auto_deploy
Browse files Browse the repository at this point in the history
Auto deploy
  • Loading branch information
serhatozdursun authored Sep 10, 2024
2 parents 7d6f8f0 + ac04767 commit fb0e2ff
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Set Node.js version to 18

- name: Install PM2
run: |
npm install -g pm2 # Install PM2 globally
- name: Deploy to server via SSH
uses: appleboy/ssh-action@v0.1.10
with:
Expand All @@ -22,21 +31,20 @@ jobs:
script: |
# Define the target directory
TARGET_DIR="repo/resume"
# Print the current directory
echo "Current directory: $(pwd)"
# Check if we are in the correct directory
CURRENT_DIR=$(basename $(pwd))
if [ "$CURRENT_DIR" != "$(basename $TARGET_DIR)" ]; then
# Navigate to the parent directory and then to the target directory
echo $CURRENT_DIR
echo "Not in the correct directory. Changing to target directory..."
# Navigate to the root directory and then to the target directory
cd ~ || exit 1
cd $TARGET_DIR || exit 1
else
echo "Already in the correct directory."
fi
# Stop the app managed by pm2, if running
pm2 stop my-app || true
pm2 stop serhatozdursun || true
# Pull the latest code from the main branch
git pull origin main
Expand All @@ -48,7 +56,7 @@ jobs:
yarn build
# Start the app with pm2
pm2 start yarn --name "my-app" -- start
pm2 start yarn --name "serhatozdursun" -- start
# Save the pm2 process list
pm2 save

0 comments on commit fb0e2ff

Please sign in to comment.