-
Notifications
You must be signed in to change notification settings - Fork 6
116 lines (98 loc) · 4.23 KB
/
main.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Update README with Sorted Papers Content
on:
push:
paths:
- 'update_template_or_data/update_paper_list.md' # listen to update_paper_list.md
- 'update_template_or_data/utils/scripts/sort_by_date.py' # listen to update_template_or_data/utils/scripts/sort_by_date.py
- 'update_template_or_data/update_readme_template.md' # listen to update_template_or_data/utils/scripts/sort_by_date.py
- '.github/workflows/main.yml'
# schedule:
# - cron: '0 0 * * *' # everyday
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v2
with:
python-version: '3.10' # 使用最新的 Python 版本
- name: Install dependencies
run: |
pip install pandas matplotlib seaborn wordcloud
- name: Run update_template_or_data/utils/scripts/sort_by_date.py
run: |
python update_template_or_data/utils/scripts/sort_by_date.py
- name: Generate keyword grouping and update temp_readme.md
run: |
# Read the pre-generated keyword grouping Markdown
if [ -f update_template_or_data/keyword_grouping.md ]; then
GROUPED_KEYWORDS=$(cat update_template_or_data/keyword_grouping.md)
else
GROUPED_KEYWORDS="No keywords available"
fi
# Insert the keyword grouping content into the template
sed -i '/{{insert_keyword_groups_here}}/{
r /dev/stdin
d
}' update_template_or_data/update_readme_template.md <<< "$GROUPED_KEYWORDS"
# - name: Generate author grouping and update temp_readme.md
# run: |
# # Initialize the output for grouped papers by authors
# GROUPED_AUTHORS=""
#
# # Iterate over all files in the paper_by_author directory
# for file in paper_by_author/*.md; do
# # Extract the author name by removing 'paper_' and '.md', and replacing '_' with spaces
# AUTHOR=$(basename "$file" .md | sed 's/^paper_//' | tr '_' ' ')
#
# # Add the author to the grouped authors section
# GROUPED_AUTHORS+="[${AUTHOR^}](paper_by_author/$(basename "$file" | sed 's/ /%20/g')) | "
# done
#
# # Trim the trailing '| ' at the end
# GROUPED_AUTHORS=${GROUPED_AUTHORS% | }
#
# # Insert the author grouping content into the template
# sed -i '/{{insert_author_groups_here}}/{
# r /dev/stdin
# d
# }' update_template_or_data/update_readme_template.md <<< "$GROUPED_AUTHORS"
- name: Generate author grouping and update temp_readme.md
run: |
# Read the pre-generated author grouping Markdown
if [ -f update_template_or_data/author_grouping.md ]; then
GROUPED_AUTHORS=$(cat update_template_or_data/author_grouping.md)
else
GROUPED_AUTHORS="No authors available"
fi
# Insert the author grouping content into the template
sed -i '/{{insert_author_groups_here}}/{
r /dev/stdin
d
}' update_template_or_data/update_readme_template.md <<< "$GROUPED_AUTHORS"
- name: Update temp_readme.md with sorted papers content
run: |
CONTENT=$(cat update_template_or_data/update_paper_list.md)
sed -i '/{{insert_all_papers_here}}/{
r /dev/stdin
d
}' update_template_or_data/update_readme_template.md <<< "$CONTENT"
- name: Overwrite README.md with updated temp_readme.md
run: |
# overwrite README.md
cp update_template_or_data/update_readme_template.md README.md
- name: Commit changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add README.md
git add paper_by_env
git add paper_by_author
git add paper_by_key
git add update_template_or_data/statistics
git commit -m "auto updates by github workflow"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}