-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (56 loc) · 2.14 KB
/
main.yml
File metadata and controls
67 lines (56 loc) · 2.14 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
name: Update Custom.xaml Daily
on:
schedule:
- cron: "0 4 * * *" # 每天北京时间中午12点
workflow_dispatch:
jobs:
update-file:
runs-on: ubuntu-latest
steps:
# 1. 检出代码
- name: Check out the repository
uses: actions/checkout@v3
# 2. 设置 Python 环境
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
# 3. 安装 Python 依赖 (包括 Playwright 库本身)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# 4. 获取 Playwright 版本 (这一步很关键,用于生成唯一的缓存 Key)
- name: Get installed Playwright version
id: playwright-version
run: echo "VERSION=$(playwright --version | awk '{print $2}')" >> $GITHUB_OUTPUT
# 5. 配置缓存
- name: Cache Playwright browsers
uses: actions/cache@v4 # 推荐使用 v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.VERSION }}
# 6. 安装浏览器 (仅当缓存未命中时运行)
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: playwright install
# 7. 运行 Python 脚本
- name: Run Python script
run: |
python main.py
# 8. 提交并推送更改
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# 防止没有更改时报错
if [[ -n $(git status -s) ]]; then
git add output/ --all
git commit -m "Update Custom output files with new Wiki content"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/CreeperIsASpy/Magazine-Homepage-PCL.git HEAD:main
else
echo "No changes to commit"
fi