mirror of
https://github.com/gelusus/wxvl.git
synced 2026-10-28 19:30:54 +00:00
add
This commit is contained in:
1 parent
b722c3f135
commit
8a4127d636
3 files changed
+74
-10
No files matched your search
@@ -0,0 +1,49 @@
|
||||
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||
|
||||
name: update
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10"
|
||||
- name: Write Issue Content to Temp File
|
||||
run: |
|
||||
issue_body=$(jq -r ".issue.body" "$GITHUB_EVENT_PATH")
|
||||
echo "$issue_body" > /tmp/issue_content.txt
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
- name: update
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
run: |
|
||||
python run.py issue | tee /tmp/update.log
|
||||
- name: Commit and push if changed
|
||||
run: |
|
||||
git config --global user.email "test"
|
||||
git config --global user.name "test"
|
||||
git add .
|
||||
MESSAGE=$(cat /tmp/update.log)
|
||||
COMMIT_MESSAGE="$MESSAGE"
|
||||
git diff-index --quiet HEAD || git commit -m "$(echo -e "$COMMIT_MESSAGE")"
|
||||
git push
|
||||
- name: Close Issue
|
||||
run: |
|
||||
TOKEN=${{ secrets.GH_TOKEN }}
|
||||
ISSUE_NUMBER=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
|
||||
API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${ISSUE_NUMBER}"
|
||||
curl -X PATCH -H "Authorization: token $TOKEN" -d '{"state":"closed"}' $API_URL
|
||||
File renamed without changes.
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import json
|
||||
import platform
|
||||
import tempfile
|
||||
@@ -83,6 +84,16 @@ def get_today_url():
|
||||
return urls
|
||||
except:
|
||||
return []
|
||||
|
||||
def get_issue_url():
|
||||
file = '/tmp/issue_content.txt'
|
||||
if os.path.exists(file):
|
||||
content = open(file,'r',encoding='utf8').read()
|
||||
urls = re.findall('(https://mp.weixin.qq.com/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)',content,re.I)
|
||||
urls = [url.rstrip(')') for url in urls]
|
||||
return urls
|
||||
return []
|
||||
|
||||
def main():
|
||||
'''主函数'''
|
||||
data_file = 'data.json'
|
||||
@@ -92,16 +103,20 @@ def main():
|
||||
os.makedirs(result_path,exist_ok=True)
|
||||
# 读取历史记录
|
||||
data = read_json(data_file, default_data=data)
|
||||
for url in get_today_url():
|
||||
if url in data:
|
||||
continue
|
||||
for file_path in get_md_path(executable_path, url):
|
||||
name = os.path.splitext(os.path.basename(file_path))[0]
|
||||
shutil.copy2(file_path,result_path)
|
||||
data[url] = name
|
||||
write_json(data_file,data)
|
||||
print(name,end='、')
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == 'today':
|
||||
urls = get_today_url()
|
||||
else:
|
||||
urls = get_issue_url()
|
||||
for url in urls:
|
||||
if url in data:
|
||||
continue
|
||||
for file_path in get_md_path(executable_path, url):
|
||||
name = os.path.splitext(os.path.basename(file_path))[0]
|
||||
shutil.copy2(file_path,result_path)
|
||||
data[url] = name
|
||||
write_json(data_file,data)
|
||||
print(name,end='、')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user