-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (42 loc) · 1.32 KB
/
main.yml
File metadata and controls
52 lines (42 loc) · 1.32 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
name: tool.bearune CICD
on:
push:
branches: [develop] # 當推送到 develop 分支時觸發
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Setup Node.js
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
# Step 3: npm install
- name: Install dependencies
run: npm install
# Step 4: Build
- name: Build application
run: npm run build # 根據你的專案需求修改
# Step 5: Setup SSH Key
- name: Install SSH key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.BEARUNE_DEPLOY_SSH }}
# Step 6: Update known_hosts
- name: Update known_hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H 172.233.65.93 >> ~/.ssh/known_hosts
# Step 7: Transfer files using rsync
- name: Transfer files
run: |
rsync -avz --delete ./dist/ root@172.233.65.93:/var/www/tool/
env:
SSH_AUTH_SOCK: ${{ env.SSH_AUTH_SOCK }} # 確保 SSH 代理可用
# Step 8: Set permissions
- name: Set permissions
run: |
ssh root@172.233.65.93 'chown -R www-data:www-data /var/www/tool'