Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

Set Label When Approved

v0.1

Set Label When Approved

play

Set Label When Approved

Set label when PR is approved

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Set Label When Approved

uses: TobKed/[email protected]

Learn more about this action in TobKed/label-when-approved-action

Choose a version

label-when-approved-action status

Get Workflow Runs action

Table of Contents generated with DocToc

Context and motivation

Label When Approved is an action that checks is Pull Request is approved and assign label to it. Label is not set or removed when Pull Request has awaiting requested changes.

Setting label is optional that only output can be used in the workflow.

The required input require_committers_approval says is approval can be done by people with read access to the repo or by anyone. It may be useful in repositories which requires committers approvals like Apache Software Foundation projects.

Inputs and outputs

Inputs

Input Required Example Comment
token yes ${{ secrets.GITHUB_TOKEN }} The github token passed from ${{ secrets.GITHUB_TOKEN }}
label no Approved by committers Label to be added/removed to the Pull Request if approved/not approved
require_committers_approval no true Is approval from user with write permission required

Outputs

Output
isApproved is Pull Reqeuest is approved
labelSet is label was set
labelRemoved is label was removed

Examples

Workflow Run event

name: Label when approved
on: pull_request_review

jobs:

  label-when-approved:
    name: "Label when approved"
    runs-on: ubuntu-latest
    outputs:
      isApprovedByCommiters: ${{ steps.label-when-approved-by-commiters.outputs.isApproved }}
      isApprovedByAnyone: ${{ steps.label-when-approved-by-anyone.outputs.isApproved }}
    steps:
      - name: Label when approved by commiters
        uses: TobKed/[email protected]
        id: label-when-approved-by-commiters
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          label: 'ready to merge (committers)'
          require_committers_approval: 'true'
      - name: Label when approved by anyone
        uses: TobKed/[email protected]
        id: label-when-approved-by-anyone
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

Development environment

It is highly recommended tu use pre commit. The pre-commits installed via pre-commit tool handle automatically linting (including automated fixes) as well as building and packaging Javascript index.js from the main.ts Typescript code, so you do not have to run it yourself.

License

MIT License covers the scripts and documentation in this project.