File tree Expand file tree Collapse file tree 2 files changed +124
-0
lines changed Expand file tree Collapse file tree 2 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy to GitHub Pages
2
+
3
+ on :
4
+
5
+ workflow_dispatch : # 手动触发
6
+ # push:
7
+ # branches: [ main ] # 当 main 分支有推送时也触发
8
+ issues :
9
+ types : [closed]
10
+
11
+ concurrency :
12
+ group : ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress : false
14
+
15
+ permissions :
16
+ contents : write
17
+ pages : write
18
+ id-token : write
19
+
20
+ jobs :
21
+ # 构建工作
22
+ build :
23
+ runs-on : ubuntu-latest
24
+ steps :
25
+ - name : Checkout
26
+ uses : actions/checkout@v4
27
+ with :
28
+ fetch-depth : 0
29
+
30
+ - name : Setup Python
31
+ uses : actions/setup-python@v4
32
+ with :
33
+ python-version : ' 3.9'
34
+
35
+ - name : Install Python dependencies
36
+ run : |
37
+ cd backend
38
+ pip install requests
39
+
40
+ - name : Fetch articles and update data
41
+ run : |
42
+ cd backend
43
+ python close.py
44
+
45
+ - name : Setup pnpm
46
+ uses : pnpm/action-setup@v3
47
+ with :
48
+ version : 8
49
+
50
+ - name : Setup Node
51
+ uses : actions/setup-node@v4
52
+
53
+ - name : Setup Pages
54
+ uses : actions/configure-pages@v4
55
+
56
+ - name : Install dependencies
57
+ run : |
58
+ cd frontend
59
+ pnpm install --no-frozen-lockfile
60
+
61
+ - name : Build
62
+ run : |
63
+ cd frontend
64
+ pnpm build
65
+
66
+ - name : Upload artifact
67
+ uses : actions/upload-pages-artifact@v3
68
+ with :
69
+ path : ./frontend/dist
70
+
71
+ - name : Commit changes
72
+ uses : actions-x/commit@v6
73
+ with :
74
+
75
+ name : GitHub Actions Autocommitter
76
+ branch : main
77
+ files : frontend/src/data/articles.json
78
+ force : true
79
+ directory : .
80
+
81
+
82
+ # 部署工作
83
+ deploy :
84
+ environment :
85
+ name : github-pages
86
+ url : ${{ steps.deployment.outputs.page_url }}
87
+ needs : build
88
+ runs-on : ubuntu-latest
89
+ steps :
90
+ - name : Deploy to GitHub Pages
91
+ id : deployment
92
+ uses : actions/deploy-pages@v4
Original file line number Diff line number Diff line change
1
+ import json
2
+
3
+ import requests
4
+
5
+ file_path = "file.json"
6
+ output_file = '../frontend/src/data/articles.json'
7
+
8
+
9
+ def geturl ():
10
+
11
+ with open (output_file , 'r' , encoding = 'utf-8' ) as f :
12
+ x = f .read ()
13
+ cabbc = json .loads (x )
14
+ loaclsnumbers = []
15
+ for issue in cabbc :
16
+ loaclsnumbers .append (issue .get ("id" ))
17
+
18
+ response = requests .get ("https://api.github.com/repos/kaozb/ai-arctl/issues?per_page=100&state=closed" )
19
+ issues = response .json ()
20
+ removeid = []
21
+ for issue in issues :
22
+ number = issue .get ("number" )
23
+ if number in loaclsnumbers :
24
+ removeid .append (number )
25
+ newarctls = [item for item in cabbc if item .get ("id" ) not in removeid ]
26
+
27
+ with open (output_file , 'w' , encoding = 'utf-8' ) as f :
28
+ json .dump (newarctls , f , ensure_ascii = False , indent = 2 )
29
+
30
+ if __name__ == '__main__' :
31
+ geturl ()
32
+ geturl ()
You can’t perform that action at this time.
0 commit comments