forked from peasoft/NoMoreWalls
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (61 loc) · 1.73 KB
/
fetch.yml
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
name: Fetch
on:
workflow_dispatch:
schedule:
# 表达式生成 https://crontab.guru/
- cron: '0 0/3 * * *'
push:
paths:
- 'sources.list'
- 'config.yml'
- 'abpwhite.txt'
- '.github/workflows/**'
- '**.py'
- 'snippets/_*'
jobs:
fetch:
runs-on: ubuntu-latest
steps:
- name: 迁出代码
uses: actions/checkout@v4
- name: 设置时区
run: sudo timedatectl set-timezone 'Asia/Shanghai'
- name: 安装 Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: 安装依赖
run: pip install -r requirements.txt
- name: 执行任务
run: python ./fetch.py
- name: 提交更改
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git pull origin master
git add list*
git add snippets/
git commit -m "$(date '+%Y-%m-%d %H:%M:%S') 抓取节点"
- name: 推送更改
uses: ad-m/github-push-action@master
with:
branch: master
- name: 计算要清除缓存的文件
id: purge_urls
run: |
sleep 5
baseUrl="https://cdn.jsdelivr.net/gh/${{ github.repository }}@master"
urls=""
for f in `find snippets -name "*.yml" -type f`; do
urls+="${baseUrl}/${f},"
done
for f in `find . -name "list*" -type f -maxdepth 1`; do
urls+="${baseUrl}/${f},"
done
echo "urls=${urls%,*}" >> $GITHUB_OUTPUT
- name: 清除 JsDelivr CDN 缓存
uses: egad13/purge-jsdelivr-cache@v1
with:
url: ${{ steps.purge_urls.outputs.urls }}
continue-on-error: true