Update README
1 file changed
tree: 6b7a4c8c0067c9d5ca16ac08e5c9e3c3aca1e20e
  1. .github/
  2. __tests__/
  3. dist/
  4. src/
  5. .eslintignore
  6. .eslintrc.json
  7. .gitignore
  8. .pre-commit-config.yaml
  9. .prettierignore
  10. .prettierrc.json
  11. action.yml
  12. jest.config.js
  13. LICENSE
  14. package-lock.json
  15. package.json
  16. README.md
  17. tsconfig.json
  18. yamllint-config.yml
README.md

Label When Approved 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

InputRequiredExampleComment
tokenyes${{ secrets.GITHUB_TOKEN }}The github token passed from ${{ secrets.GITHUB_TOKEN }}
labelnoApproved by committersLabel to be added/removed to the Pull Request if approved/not approved
require_committers_approvalnotrueIs approval from user with write permission required
commentnoPR approved by at least one committer and no changes requested.Add optional comment to the PR when approved (requires label input to be set)

Outputs

Output
isApprovedis Pull Reqeuest approved
labelSetwas label set
labelRemovedwas label 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/label-when-approved-action@v1.1
        id: label-when-approved-by-commiters
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          label: 'ready to merge (committers)'
          require_committers_approval: 'true'
          comment: 'PR approved by at least one committer and no changes requested.'
      - name: Label when approved by anyone
        uses: TobKed/label-when-approved-action@v1.1
        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.