
Some checks failed
Generate README based on repo name and commits / generate-readme (push) Failing after 11s
50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
name: Generate README based on repo name and commits
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # 可根据实际情况修改为你的默认分支
|
|
|
|
jobs:
|
|
generate-readme:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: ActionDemo
|
|
run: |
|
|
git clone https://git.linuxacme.com/iorebuild/ActionDemo.git .
|
|
|
|
- name: Get repository name
|
|
id: repo-name
|
|
run: |
|
|
REPO_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)
|
|
echo "::set-output name=name::$REPO_NAME"
|
|
|
|
- name: Get recent commits
|
|
id: recent-commits
|
|
run: |
|
|
COMMITS=$(git log --pretty=format:"- %s (%an, %ad)" --date=short -n 5)
|
|
echo "::set-output name=commits::$COMMITS"
|
|
|
|
- name: Generate README
|
|
run: |
|
|
cat << EOF > README.md
|
|
# ${{ steps.repo-name.outputs.name }}
|
|
|
|
## Recent Commits
|
|
${{ steps.recent-commits.outputs.commits }}
|
|
EOF
|
|
|
|
- name: Commit and push changes
|
|
env:
|
|
GIT_REPO_TOKEN: ${{ secrets.AUTOGENERATEREADME }} # 假设你已经将令牌存储为 GITHUB_TOKEN 机密
|
|
run: |
|
|
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 README.md. Skipping commit."
|
|
else
|
|
git commit -m "Update README with recent commits"
|
|
git push https://${GIT_REPO_TOKEN}@git.linuxacme.com/ActionDemo.git
|
|
fi |