Home

Awesome

Repo Automator - GitHub Action

GitHub Action that automates some common repository operations like validating PR description, changelog and credits.

Support Level Release Version License CodeQL

Overview

This GitHub Action Helps with the following operations:

Configuration

Required secrets

Other optional configurations

KeyDefaultDescription
assign-prtrueWhether to assign PR to author
assign-issuestrueWhether to assign issue with PR assignee when linked PR is merged
add-milestonetrueWhether to automatically add a Milestone to a PR
fail-labelneeds:feedbackThe label to be added to PR if the pull request doesn't pass the validation. Pass false to skip adding the label.
pass-labelneeds:code-reviewThe label to be added to PR if the pull request pass the validation. Pass false to skip adding the label.
conflict-labelneeds:refreshThe label to be added to PR if the pull request has conflicts. Pass false to skip adding the label.
comment-template{author} thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this?Comment template for adding comment on PR if it doesn't pass the validation. Pass false to skip adding the comment.
conflict-comment{author} thanks for the PR! Could you please rebase your PR on top of the latest changes in the base branch?Comment template for adding comment on PR if it has conflicts. Pass false to skip adding the comment.
issue-welcome-messagefalseComment template for adding a welcome message on an issue for first-time issue creators
pr-welcome-messagefalseComment template for adding a welcome message on a PR for first-time PR creators
issue-commentfalseComment template for adding a comment to a newly opened issue
pr-commentfalseComment template for adding a comment to a newly opened pull request
comment-ignore-users-List of users to ignore for adding comments when the issue or PR is opened by them. Add prefix team: if you want to ignore users from the team.
reviewersteam:open-source-practiceList of Reviewers to request PR review after passing all validation checks. Add prefix team: if you want to request review from the team.
sync-pr-branchfalseWhether to enable automatic synchronization of the pull request branch with the base branch
validate-descriptiontrueWhether to validate the pull request description. Pass false to disable description validation
validate-changelogtrueWhether to validate the pull request changelog entry. Pass false to disable changelog validation
validate-creditstrueWhether to validate the props given in pull request. Pass false to disable credits validation
wait-ms15000Time to wait in milliseconds between retries to check PR mergeable status
max-retries5Maximum number of retries to check PR mergeable status

Example Workflow File

To get started, you will want to copy the contents of the given example into .github/workflows/repo-automator.yml and push that to your repository. You are welcome to name the file something else.

name: 'Repo Automator'
on:
  issues:
    types:
      - opened
  push:
    branches:
      - develop
  pull_request:
    types:
      - opened
      - edited
      - synchronize
      - converted_to_draft
      - ready_for_review
    branches:
      - develop

jobs:
  Validate:
    runs-on: ubuntu-latest
    steps:
      - uses: 10up/action-repo-automator@trunk
        with:
          fail-label: 'needs:feedback'
          pass-label: 'needs:code-review'
          conflict-label: 'needs:refresh'
          issue-welcome-message: |
            Welcome {author}! 👋 Thank you for opening your first issue! We're glad to have you here and appreciate your contribution. If you need any help or have questions, feel free to ask. Happy coding! 🚀
          reviewers: |
            GITHUB_USERNAME
            team:GITHUB_TEAM_SLUG
          issue-comment: |
            Hi {author},

            Thank you for reporting this issue! We appreciate your feedback and will look into it promptly.
          comment-ignore-users: |
            GITHUB_USERNAME
            team:GITHUB_TEAM_SLUG
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

(Optional) GitHub Personal Access Token (PAT)

When the default GITHUB_TOKEN doesn't have the necessary permissions, you need to create a new GitHub personal access token.

For example, if you'd like to request a review from GitHub teams, you need to create a new PAT because the default GITHUB_TOKEN doesn't have the permission to request a review from a team.

The PAT needs to have the repo scope and the account used for create a PAT needs to have the write permission to the repository. Once you create a new PAT, set it as a secret in your repository.

You have to pass your PAT to GITHUB_TOKEN environment variable, as below.

env:
  GITHUB_TOKEN: ${{ secrets.PAT }}

Support Level

Beta: This project is quite new and we're not sure what our ongoing support level for this will be. Bug reports, feature requests, questions, and pull requests are welcome. If you like this project please let us know, but be cautious using this in a Production environment!

Known Caveats/Issues

Fork-based PRs - When creating a pull request from a fork, GitHub limits the permissions of GITHUB_TOKEN and other API access tokens. This means that the provided GITHUB_TOKEN will not have write access, and the secrets will not be accessible. As a result, some operations (such as adding labels, auto-assigning pull requests, and requesting reviews automatically) will be skipped for pull requests from forked repositories, as these operations require write access to perform successfully.

Merge Conflicts - Sometimes, GitHub does not reliably compute the mergeable status, which is essential for this action to detect merge conflicts. When the base branch (like "main") is updated, the mergeable status becomes UNKNOWN until it is requested by someone, like this action. GitHub then tries to figure out the status with a background process. This process is usually fast and straightforward, but there's no absolute assurance, and occasional problems on GitHub's end may arise. If you need more time for the Pull Request to be processed, you can adjust the settings for max-retries and wait_ms to extend the timeout before giving up.

Changelog

A complete listing of all notable changes to Repo Automator - GitHub Action are documented in CHANGELOG.md.

Contributing

Please read CODE_OF_CONDUCT.md for details on our code of conduct, CONTRIBUTING.md for details on the process for submitting pull requests to us, and CREDITS.md for a list of maintainers, contributors, and libraries used in this repository.

Like what you see?

<a href="http://10up.com/contact/"><img src="https://10up.com/uploads/2016/10/10up-Github-Banner.png" width="850" alt="Work with us at 10up"></a>