-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.56 KB
/
static.yml
File metadata and controls
57 lines (48 loc) · 1.56 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
name: Deploy static content to Pages
on:
push:
branches: ["main"]
schedule:
# 每周一 12:00 北京时间 = 04:00 UTC(周一),刷新开源项目的 GitHub star 数据
- cron: '0 4 * * 1'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
# 抓取 GitHub star,生成 assets/js/gh-stars-data.js(仅用 Python 标准库,无需额外依赖)
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Fetch GitHub stars
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python scripts/fetch_stars.py
# 给所有静态资源打上统一的缓存版本号(提交短 SHA),避免手动维护 ?v= 导致版本漂移/缓存错乱
- name: Stamp asset cache-busting version
run: python scripts/bump_version.py "${GITHUB_SHA::12}"
# 这里直接上传整个仓库根目录作为 Pages 内容
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: "." # 注意这里部署的是整个仓库根目录
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5