Update README.md #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |