-
Notifications
You must be signed in to change notification settings - Fork 12
75 lines (61 loc) · 2.25 KB
/
deploy_docs.yaml
File metadata and controls
75 lines (61 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Deploy documentation
on:
pull_request:
branches:
- v2.x
types:
- closed
jobs:
test_build_deploy:
name: Test, Build, and Deploy
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.ref == 'refs/heads/v2.x'
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Cache dependencies (only npm)
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-mintlify-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-mintlify-
# Step 3: SSH into server and deploy
- name: Deploy to server
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Navigating to project directory"
cd ${{ secrets.PROJECT_PATH }}
# Ensure proper permissions for project files
echo "Ensuring correct file permissions..."
sudo chown -R $USER:$USER ${{ secrets.PROJECT_PATH }}
sudo chmod -R 755 ${{ secrets.PROJECT_PATH }}
# Use nvm to install and use Node.js LTS on the server
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm
nvm install --lts
nvm use --lts
# Verify Node.js version
echo "Node.js version on server:"
node -v
echo "Resetting any local changes"
git reset --hard HEAD
echo "Pulling the latest code"
git pull origin
# Kill the process using port 3000 safely
echo "Ensuring port 3000 is free..."
npx kill-port 3000 || true
# Navigate to the docs directory
echo "Navigating to docs directory"
cd docs
npm install -g mintlify
# Run Mintlify dev to start the documentation server
echo "Starting Mintlify dev..."
screen -dmS mintlify mintlify dev > app_output.log 2>&1
echo "Deployment complete."