-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (45 loc) · 1.4 KB
/
Copy pathbuild.yml
File metadata and controls
54 lines (45 loc) · 1.4 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
name: Build Navigation Site
on:
repository_dispatch:
types: [update-navigation]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Fetch navigation data from n8n
env:
N8N_WEBHOOK_URL: ${{ secrets.N8N_WEBHOOK_URL }}
run: |
echo "Fetching data from n8n..."
HTTP_CODE=$(curl -s -o src/data/navigation.json -w "%{http_code}" "$N8N_WEBHOOK_URL" || echo "000")
if [ "$HTTP_CODE" = "200" ] && [ -s src/data/navigation.json ]; then
echo "✅ Data fetched successfully!"
else
echo "⚠️ Failed to fetch data (HTTP: $HTTP_CODE)"
if [ ! -s src/data/navigation.json ]; then
echo '[]' > src/data/navigation.json
fi
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build nav.html
run: npm run build
- name: Commit and Push
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: 更新导航页面"
file_pattern: "src/data/navigation.json dist/nav.html"