File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy to Production Server
2+
3+ on :
4+ push :
5+ branches : [ main, master ]
6+ workflow_dispatch : # Allow manual triggers
7+
8+ jobs :
9+ deploy :
10+ runs-on : self-hosted
11+
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v4
15+
16+ - name : Setup Node.js
17+ uses : actions/setup-node@v4
18+ with :
19+ node-version : ' 20.18'
20+
21+ - name : Setup pnpm
22+ uses : pnpm/action-setup@v2
23+ with :
24+ version : latest
25+
26+ - name : Get pnpm store directory
27+ shell : bash
28+ run : |
29+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
30+
31+ - name : Setup pnpm cache
32+ uses : actions/cache@v3
33+ with :
34+ path : ${{ env.STORE_PATH }}
35+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+ restore-keys : |
37+ ${{ runner.os }}-pnpm-store-
38+
39+ - name : Install dependencies
40+ run : pnpm install --frozen-lockfile
41+
42+ - name : Build application
43+ run : pnpm run build
44+ env :
45+ NODE_OPTIONS : " --max-old-space-size=1024"
46+
47+ - name : Deploy with PM2
48+ run : |
49+ pm2 reload ecosystem.config.js --env production || pm2 start ecosystem.config.js --env production
50+ pm2 save
51+
52+ - name : Health check
53+ run : |
54+ sleep 10
55+ curl -f http://localhost:3000 || exit 1
56+
57+ - name : Notify deployment status
58+ if : always()
59+ run : |
60+ if [ "${{ job.status }}" == "success" ]; then
61+ echo "✅ Deployment successful"
62+ else
63+ echo "❌ Deployment failed"
64+ exit 1
65+ fi
You can’t perform that action at this time.
0 commit comments