Skip to content

Latest commit

 

History

History
125 lines (90 loc) · 5.24 KB

File metadata and controls

125 lines (90 loc) · 5.24 KB

GitHub license GitHub release tag * GitHub repository stargazers

Require Team Approval

Require N number of PR approvals from members of a GitHub team. Used to enforce pre-merge PR checks more explicitly than GitHub's native CODEOWNERS file.


Usage Examples

#1 pull_request event requiring 1 approval each from 2 teams

The bare minimum configuration requires a GitHub access token with 'read:org' scope and the team name whose approval is required. The default number of approvals is set to 1 on the PR which triggered the workflow and can be called multiple times for different teams.

on:
  pull_request:

jobs:
  check:
    runs-on: ubuntu-latest

steps:
  - name: Require DEV team approval
    uses: op5dev/require-team-approval@v1
    with:
      team: dev-team
      token: ${{ secrets.CI_PAT }}

  - name: Require QA team approval
    uses: op5dev/require-team-approval@v1
    with:
      team: qa-team
      token: ${{ secrets.CI_PAT }}

#2 pull_request_review event requiring 2 approvals with outputs

This configuration demonstrates a more targeted approach by checking for approvals only when an approved review is submitted. The outputs provide detailed information about the approvals, both by the team and the PR in general, for use in subsequent steps as counts or named lists.

on:
  pull_request_review:
    types: [submitted]

jobs:
  check:
    if: github.event.review.state == 'approved'
    runs-on: ubuntu-latest

    steps:
      - name: Require QA team approval x2
        id: approval
        uses: op5dev/require-team-approval@v1
        with:
          approvals: 2
          team: qa-team
          token: ${{ secrets.CI_PAT }}

      - run: |
          echo "Got ${{ steps.approval.outputs.team-approvals-count }} / 2 approvals from QA."
          echo "Got ${{ steps.approval.outputs.pr-approvals-count }} approvals in total."

Parameters

Inputs

Name Description
team
(required)
Team whose approval is required.
Example: qa-team
token
(required)
GitHub access token with 'read:org' scope.
Example: secrets.CI_PAT
approvals Count of approvals required.
Default: 1
pr-number Override PR number.
Example: 42

Outputs

Name Description
pr-approvals List of approvals on the PR.
Example: [dev-1,qa-1]
pr-approvals-count Count of approvals on the PR.
Example: 1
team-approvals List of approvals from the team.
Example: [qa-1]
team-approvals-count Count of approvals from the team.
Example: 1
team-members List of team members.
Example: [dev-1,dev-2,dev-3]
team-members-count Count of team members.
Example: 1

Security

View security policy and reporting instructions.


Changelog

View all notable changes to this project in Keep a Changelog format, which adheres to Semantic Versioning.

Tip

All forms of contribution are very welcome and deeply appreciated for fostering open-source projects.


License