-
Notifications
You must be signed in to change notification settings - Fork 3
89 lines (74 loc) · 2.03 KB
/
update_hosts.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Update hosts
on:
push:
paths:
- 'setHosts.py'
- 'setHosts_Classic.py'
- 'requirements.txt'
branches:
- 'master'
schedule:
- cron: '0 */4 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
format-fix:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install formatting tools
run: |
pip install black flake8 isort
- name: Run and fix formatting
run: |
#black --line-length 88 .
black --line-length 88 --no-cache setDNS.py
isort .
echo “继续”
flake8 --max-line-length=88 .
# 提交修复的代码
- name: Commit and push fixes
if: success() || failure()
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add .
git commit -m "Fix formatting issues" || echo "No changes to commit"
git push
update-hosts:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo pip install -r requirements.txt
- name: Run hosts update script1
run: |
sudo python3 setHosts.py
# 提交并推送更新(仅在文件变更时)
- name: Commit and push changes
uses: EndBug/add-and-commit@v9
with:
message: "Update hosts list"
add: |
hosts
README.md
push: true