Skip to content

update readme

update readme #201

Workflow file for this run

name: Update README with Sorted Papers Content
on:
push:
paths:
- 'update_template_or_data/update_paper_list.md' # 监听 update_paper_list.md 文件的更新
- 'update_template_or_data/utils/scripts/sort_by_date.py' # 监听 update_template_or_data/utils/scripts/sort_by_date.py 脚本的更新
- 'update_template_or_data/update_readme_template.md' # 监听 update_template_or_data/utils/scripts/sort_by_date.py 脚本的更新
- '.github/workflows/main.yml'
# schedule:
# - cron: '0 0 * * *' # 每天定时运行(0点)
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: |
# Define fixed priority keywords
PRIORITY_KEYWORDS="model framework dataset benchmark safety survey"
# Initialize the output for grouped papers
GROUPED_KEYWORDS=""
# Generate priority keyword sections first
for key in $PRIORITY_KEYWORDS; do
FILE="paper_by_key/paper_${key}.md"
if [ -f "$FILE" ]; then
GROUPED_KEYWORDS+="[${key^}](paper_by_key/paper_${key}.md) | "
fi
done
GROUPED_KEYWORDS+=$'\n'
# Generate sections for all other keywords dynamically
for file in paper_by_key/*.md; do
KEYWORD=$(basename "$file" .md | sed 's/^paper_//' | tr '_' ' ')
# Skip priority keywords already processed
if [[ "$PRIORITY_KEYWORDS" != *"${KEYWORD}"* ]]; then
GROUPED_KEYWORDS+="[${KEYWORD^}](paper_by_key/$(basename "$file" | sed 's/ /%20/g')) | "
fi
done
# Trim the trailing '| ' at the end
GROUPED_KEYWORDS=${GROUPED_KEYWORDS% | }
# Insert the 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: Update temp_readme.md with sorted papers content
run: |
# 读取更新后的 update_template_or_data/update_paper_list.md 内容
CONTENT=$(cat update_template_or_data/update_paper_list.md)
# 使用 sed 插入 content 到 temp_readme.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: |
# 覆盖 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 }}