Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto deploy #51

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading