72 lines
2.4 KiB
YAML
72 lines
2.4 KiB
YAML
name: 自动生成README.md文件
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
create-readme:
|
|
runs-on: ubuntu-latest
|
|
|
|
if: "!contains(github.event.head_commit.message, 'AutoGenerateREADME.md')"
|
|
|
|
steps:
|
|
- name: 删除本地仓库副本
|
|
env:
|
|
REPO_NAME: ${{ github.event.repository.name }}
|
|
run: |
|
|
if [ -d "$REPO_NAME" ]; then
|
|
rm -rf "$REPO_NAME"
|
|
fi
|
|
|
|
- name: 检出仓库
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.AUTOGENERATE }}
|
|
GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
|
CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
|
run: |
|
|
CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}"
|
|
git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" .
|
|
|
|
- name: 创建README.md
|
|
run: |
|
|
if [ -f README.md ]; then
|
|
rm README.md
|
|
fi
|
|
|
|
- name: 添加项目标题到README.md文件
|
|
run: |
|
|
echo "# ActionDemo测试文档标题" > README.md
|
|
|
|
# - name : 获取提交记录到README.md文件
|
|
# run: |
|
|
# # 获取提交记录并追加到 README.md
|
|
# git log --pretty=format:"- %h %ad %s" --date=short >> README.md
|
|
|
|
- name: 获取版本发布记录到README.md文件
|
|
run: |
|
|
echo "## 版本发布记录" >> README.md
|
|
# 获取标签信息并格式化输出
|
|
git tag -l --sort=-creatordate | while read tag; do
|
|
tag_date=$(git log -1 --format=%ad --date=short $tag)
|
|
tag_message=$(git tag -n9 $tag | sed 's/^[[:space:]]*//')
|
|
echo "- **$tag** ($tag_date): $tag_message" >> README.md
|
|
done
|
|
|
|
- name: 重新提交仓库
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.AUTOGENERATE }}
|
|
GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
|
CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
|
run: |
|
|
CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}"
|
|
git config --local user.email "liyepan@linuxacme.com"
|
|
git config --local user.name "iorebuild"
|
|
git add README.md
|
|
if git diff --staged --quiet; then
|
|
echo "No changes to commit."
|
|
else
|
|
git commit -m "AutoGenerateREADME.md"
|
|
git push "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}"
|
|
fi |