-
Notifications
You must be signed in to change notification settings - Fork 7
65 lines (53 loc) · 1.87 KB
/
Copy pathdeploy.yml
File metadata and controls
65 lines (53 loc) · 1.87 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
name: Deploy Production
on:
push:
branches: ['leader']
env:
NODE_VERSION: '20'
jobs:
deploy:
runs-on: self-hosted
# Only run if Quality Gate passed (implied by branch protection, but good to be explicit)
if: github.ref == 'refs/heads/leader'
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: 🟢 Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: 📥 Install Dependencies
run: pnpm install
- name: 🏗️ Build Standalone Artifact
env:
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET_BUILD_PLACEHOLDER }}
NEXTAUTH_URL: 'http://localhost:3000'
run: |
# 1. Build Next.js (Standalone enabled in next.config.js)
pnpm run build
# 2. Package Artifact (Hybrid Strategy)
./scripts/package.sh
- name: 🚚 Transfer Artifact
env:
PROD_HOST: ${{ secrets.PROD_HOST }}
PROD_USER: ${{ secrets.PROD_USER }}
PROD_PATH: ${{ secrets.PROD_PATH }}
run: |
# Transfer the Release Archive (contains all scripts)
scp release.tar.gz $PROD_USER@$PROD_HOST:$PROD_PATH/
- name: 🚀 Execute Deployment
env:
PROD_HOST: ${{ secrets.PROD_HOST }}
PROD_USER: ${{ secrets.PROD_USER }}
PROD_PATH: ${{ secrets.PROD_PATH }}
run: |
# Extract tarball and run deploy script (which it contains)
ssh $PROD_USER@$PROD_HOST "bash -l -c 'cd $PROD_PATH && tar -xzf release.tar.gz --overwrite && ./scripts/deploy-artifact.sh'"