ActionDemo/.gitea/workflows/AutoGenerateREADME.yaml
2025-04-10 15:50:16 +08:00

48 lines
1.6 KiB
YAML

name: AutoGenerateREADME.md
on:
push:
branches:
- main
jobs:
create-readme:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'AutoGenerateREADME.md')"
steps:
- name: Checkout code from Gitea
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: Touch New README.md
run: |
if [ -f README.md ]; then
rm README.md
fi
- name: Get commit history and write to README
run: |
echo "# ActionDemo测试文档标题" > README.md
- name: Commit and push changes
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 "Create README with commit history"
git push "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}"
fi