-
Notifications
You must be signed in to change notification settings - Fork 157
128 lines (101 loc) · 3.09 KB
/
Copy pathupdate-deploy.yml
File metadata and controls
128 lines (101 loc) · 3.09 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: 更新数据并部署
on:
schedule:
- cron: '17 * * * *'
push:
branches: [main, dev]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "deploy"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
- uses: pnpm/action-setup@v3
with:
version: 8.4.0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Type check
run: pnpm typecheck
- name: Restore previous feed data
run: |
mkdir -p public
if git ls-remote --exit-code --heads origin deploy >/dev/null 2>&1; then
git fetch origin deploy --depth=1
if git cat-file -e FETCH_HEAD:data 2>/dev/null; then
rm -rf public/data
git archive --format=tar FETCH_HEAD data | tar -x -C public
echo "Restored $(find public/data -type f | wc -l | tr -d ' ') feed data files from deploy branch"
else
echo "No data directory found on deploy branch"
fi
else
echo "No deploy branch found, skipping feed data restore"
fi
- name: Update RSS feeds
run: pnpm update-feeds
env:
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
LLM_API_BASE: ${{ secrets.LLM_API_BASE }}
LLM_NAME: ${{ secrets.LLM_NAME }}
- name: Build static site
run: pnpm build
- name: Copy vercel config to output
run: cp vercel.json ./out/
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: site-build
path: ./out
retention-days: 1
deploy-github-pages:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: site-build
path: ./out
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: ./out
- id: deployment
uses: actions/deploy-pages@v4
deploy-branch:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: site-build
path: ./build-output
- name: Deploy to deploy branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Always create a fresh orphan branch (no history)
git checkout --orphan deploy-new
# Remove all existing files
git rm -rf . 2>/dev/null || true
# Copy build output
cp -r build-output/* .
rm -rf build-output
# Add and commit
git add -A
git commit -m "Deploy: $(date +'%Y-%m-%d %H:%M:%S')"
# Force push to deploy branch (replaces all history)
git push -f origin deploy-new:deploy