I wanted to build something simple but yet useful for open source maintainers. So here's what I built: an action to automatically generate a CONTRIBUTORS.md file based on a project's top contributors, using the GitHub API to pull information about the project. The workflow then uses another action to create a pull request or commit the changes directly to the same repository where the workflow is configured.
The action runs a single-command application created with Minicli, a minimalist command-line framework for building PHP CLI commands.
The application, action, and example workflows can be found here:
This GitHub Action updates a CONTRIBUTORS file with the top contributors from the specified project, pulling contents from the GitHub API. You can use it in combination with an action to push changes directly into your project's main branch, or with an action that creates a PR with the updated file.
Supported Configuration via Environment Variables:
CONTRIB_REPOSITORY: The repository you want to pull contributors from. This is mandatory.
CONTRIB_OUTPUT_FILE: The file you want to generate, default set to CONTRIBUTORS.md.
CONTRIB_STENCIL_DIR: Where to find Stencil templates. Default set to .stencil.
CONTRIB_TEMPLATE: The stencil template to use - you can use this to customize the generated markdown file. Default set to the included contributors.tpl file.
CONTRIB_IGNORE: A comma-separated string with users to ignore. Default set to github-actions[bot],renovate-bot,dependabot.
You need to replace the CONTRIB_REPOSITORY value with the GitHub project you want to pull contributors from.
If you'd prefer to create a pull request instead of committing the changes directly to the main branch, you can use the create-pull-request action instead. For that, you'll also need to include the actions/checkout GitHub Action:
name:Update CONTRIBUTORS fileon:schedule:-cron:"001**"workflow_dispatch:jobs:main:runs-on:ubuntu-lateststeps:-uses:actions/checkout@v2-uses:minicli/action-contributors@v3name:"UpdateaprojectsCONTRIBUTORSfile"env:CONTRIB_REPOSITORY:'minicli/minicli'CONTRIB_OUTPUT_FILE:'CONTRIBUTORS.md'-name:Create a PRuses:peter-evans/create-pull-request@v3with:commit-message:Update Contributorstitle:"[automated]UpdateContributorsFile"token:${{ secrets.GITHUB_TOKEN }}