Skip to content

Update sync_readme.yml #55

Update sync_readme.yml

Update sync_readme.yml #55

name: Combine README Files
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
combine-readmes:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Combine README files
run: |
# Ensure the main README exists
touch README.md
# Find the line number where "## πŸ“Š Leaderboard" appears
leaderboard_line=$(grep -n "## πŸ“Š Leaderboard" README.md | cut -d: -f1)
if [ -n "$leaderboard_line" ]; then
# If the line exists, remove everything after it
sed -i "${leaderboard_line},\$d" README.md
# Add the Leaderboard header back
echo "## πŸ“Š Leaderboard" >> README.md
# Append the content of SECONDARY_README.md
cat files/SECONDARY_README.md >> README.md
else
# If the line doesn't exist, append the Leaderboard header and content to the end of README.md
echo -e "\n## πŸ“Š Leaderboard" >> README.md
cat files/SECONDARY_README.md >> README.md
fi
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "Combine README files" || echo "No changes to commit"
git push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}