From 397842fa9aa4bcf65d08d9d6dfb122b771496fc2 Mon Sep 17 00:00:00 2001 From: Takehiro Suzuki Date: Thu, 18 Jul 2024 17:24:38 +0900 Subject: [PATCH] add (#456) --- .../update-contributor-highlights.yml | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 .github/workflows/update-contributor-highlights.yml diff --git a/.github/workflows/update-contributor-highlights.yml b/.github/workflows/update-contributor-highlights.yml new file mode 100644 index 000000000..6d2674ad2 --- /dev/null +++ b/.github/workflows/update-contributor-highlights.yml @@ -0,0 +1,146 @@ +name: Update Contributor Highlights + +on: + schedule: + - cron: "0 0 * * 0" # Every Sunday at midnight + workflow_dispatch: + +jobs: + update-highlights: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # All history + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install PyGithub + + - name: Calculate highlights + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + python <= PLATINUM_THRESHOLD and username not in EXCLUDED_USERS + ] + + logging.info(f"Platinum contributors: {platinum_contributors}") + + platinum_icon = "🏆" + section_title = f"## {platinum_icon} Significant Contributors\n" + + platinum_md = section_title + "\n".join( + [ + f"- [{username}](https://github.com/{username})" + for username, score in platinum_contributors + ] + ) + + + readme_path = "README.md" + with open(readme_path, "r") as file: + readme_content = file.read() + + # Find the "## Contacts" section + contacts_start = readme_content.find("## Contacts") + contacts_end = readme_content.find("\n\n", contacts_start) + + # Find the "## Contributors" section + contributors_start = readme_content.find("## Contributors", contacts_end) + # Insert the platinum contributors section between "## Contacts" and "## Contributors" + new_readme_content = ( + readme_content[:contacts_end] + + "\n\n" + + platinum_md + + "\n\n" + + readme_content[contributors_start:] + ) + + with open(readme_path, "w") as file: + file.write(new_readme_content) + EOF + + - name: Commit changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "Update contributor highlights" || echo "No changes to commit" + git push + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Update contributor highlights" + branch: update-contributor-highlights + title: "Update Contributor Highlights" + body: "This pull request updates the contributor highlights in the README.md file."