Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow

My Workflow

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…


This content originally appeared on DEV Community and was authored by Erika Heidi

My Workflow

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.

Automated pull request with github actions

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:

GitHub logo minicli / action-contributors

GitHub Action to dynamically update CONTRIBUTORS file

Generate / Update CONTRIBUTORS File - GitHub Action

This GitHub Action updates a CONTRIBUTORS file with the top contributors from the specified project, pulling contents from the GitHub API.

Example Usage

This action is made to use in conjunction with test-room-7/action-update-file in order to automatically commit an updated CONTRIBUTORS file in a fixed interval.

The following example sets a workflow to update the file once a month, committing the changes directly to the main project's branch:

name: Update CONTRIBUTORS file
on
  schedule:
    - cron: "0 0 1 * *"
  workflow_dispatch:
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: minicli/action-contributors@v3
        name: "Update a projects CONTRIBUTORS file"
      - name: Commit changes
        uses: test-room-7/action-update-file@v1
        with:
          file-path: 'CONTRIBUTORS.md'
          commit-msg: Update Contributors
          github-token: ${{ secrets.GITHUB_TOKEN }}
        env:
          CONTRIB_REPOSITORY: 'minicli/minicli'

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

Here is an example workflow to run this action once a month and commit the changes directly to the main project's branch:

name: Update CONTRIBUTORS file
on:
  schedule:
    - cron: "0 0 1 * *"
  workflow_dispatch:
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: minicli/action-contributors@v2
        name: 'Update a projects CONTRIBUTORS file'
      - name: Update resources
        uses: test-room-7/action-update-file@v1
        with:
          file-path: 'CONTRIBUTORS.md'
          commit-msg: Update Contributors
          github-token: ${{ secrets.GITHUB_TOKEN }}
        env:
          CONTRIB_REPOSITORY: 'minicli/minicli'
          CONTRIB_OUTPUT_FILE: 'CONTRIBUTORS.md'

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 file
on:
  schedule:
    - cron: "0 0 1 * *"
  workflow_dispatch:
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: minicli/action-contributors@v3
        name: "Update a projects CONTRIBUTORS file"
      - name: Create a PR
        uses: peter-evans/create-pull-request@v3
        with:
          commit-message: Update Contributors
          title: "[automated] Update Contributors File"
          token: ${{ secrets.GITHUB_TOKEN }}
        env:
          CONTRIB_REPOSITORY: 'minicli/minicli'
          CONTRIB_OUTPUT_FILE: 'CONTRIBUTORS.md'

Additional Resources / Info

Projects using this action:


This content originally appeared on DEV Community and was authored by Erika Heidi


Print Share Comment Cite Upload Translate Updates
APA

Erika Heidi | Sciencx (2021-11-16T18:15:07+00:00) Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow. Retrieved from https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/

MLA
" » Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow." Erika Heidi | Sciencx - Tuesday November 16, 2021, https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/
HARVARD
Erika Heidi | Sciencx Tuesday November 16, 2021 » Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow., viewed ,<https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/>
VANCOUVER
Erika Heidi | Sciencx - » Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/
CHICAGO
" » Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow." Erika Heidi | Sciencx - Accessed . https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/
IEEE
" » Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow." Erika Heidi | Sciencx [Online]. Available: https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/. [Accessed: ]
rf:citation
» Automatically update your CONTRIBUTORS file with this GitHub Action + Workflow | Erika Heidi | Sciencx | https://www.scien.cx/2021/11/16/automatically-update-your-contributors-file-with-this-github-action-workflow/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.