{"id":17359929,"url":"https://github.com/tobked/label-when-approved-action","last_synced_at":"2025-04-15T00:13:38.010Z","repository":{"id":53481622,"uuid":"306855926","full_name":"TobKed/label-when-approved-action","owner":"TobKed","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-04T17:04:31.000Z","size":258,"stargazers_count":7,"open_issues_count":4,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T00:13:19.425Z","etag":null,"topics":["actions","github","github-action","github-actions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TobKed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-24T10:09:27.000Z","updated_at":"2022-11-08T20:29:37.000Z","dependencies_parsed_at":"2024-10-25T04:19:22.594Z","dependency_job_id":"daebf8d4-aa93-4dce-a18d-d8d921eaa4a6","html_url":"https://github.com/TobKed/label-when-approved-action","commit_stats":{"total_commits":10,"total_committers":3,"mean_commits":"3.3333333333333335","dds":0.5,"last_synced_commit":"0058d0094da27e116fad6e0da516ebe1107f26de"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TobKed%2Flabel-when-approved-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TobKed%2Flabel-when-approved-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TobKed%2Flabel-when-approved-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TobKed%2Flabel-when-approved-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TobKed","download_url":"https://codeload.github.com/TobKed/label-when-approved-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981271,"owners_count":21193147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","github","github-action","github-actions"],"created_at":"2024-10-15T19:13:35.409Z","updated_at":"2025-04-15T00:13:37.993Z","avatar_url":"https://github.com/TobKed.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Label When Approved action\n\n\u003cp\u003e\u003ca href=\"https://github.com/TobKed/label-when-approved-action/actions\"\u003e\n\u003cimg alt=\"label-when-approved-action status\"\n    src=\"https://github.com/TobKed/label-when-approved-action/workflows/Test%20the%20build/badge.svg\"\u003e\u003c/a\u003e\n\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n- [Context and motivation](#context-and-motivation)\n- [Inputs and outputs](#inputs-and-outputs)\n  - [Inputs](#inputs)\n  - [Outputs](#outputs)\n- [Examples](#examples)\n    - [Workflow Run event](#workflow-run-event)\n    - [Pull Request Review event](#pull-request-review-event)\n- [Development environment](#development-environment)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# Context and motivation\n\nLabel When Approved is an action that checks is Pull Request is approved and assign label to it.\nLabel is not set or removed when Pull Request has awaiting requested changes.\n\nSetting label is optional that only output can be used in the workflow.\n\nThe required input `require_committers_approval` says is approval can be done by people with read access to the repo\nor by anyone. It may be useful in repositories which requires committers approvals like [Apache Software Foundation](https://github.com/apache/)\nprojects. By default, when the PR does not have \"approved\" status or looses its aproval status the label is removed.\nThis behaviour can be disabled when `remove_label_when_approval_missing` is set to false.\n\nIt can be used in workflows triggered by \"pull_request_review\" or \"workflow_run\".\nWhen used on \"pull_request_review\" any workflows triggered from pull request created from fork will fail\ndue to insufficient permissions. Because of this support for \"workflow_run\" was added.\nIt should be triggered by workflows \"pull_request_review\" and requires additional input `pullRequestNumber`.\nPull request number can be obtained by using [potiuk/get-workflow-origin)](https://github.com/potiuk/get-workflow-origin) action (see example [workflow-run-event](#workflow-run-event)).\n\n\n# Inputs and outputs\n\n## Inputs\n\n| Input                                | Required | Example                                                           | Comment                                                                       |\n|--------------------------------------|----------|-------------------------------------------------------------------|-------------------------------------------------------------------------------|\n| `token`                              | yes      | `${{ secrets.GITHUB_TOKEN }}`                                     | The github token passed from `${{ secrets.GITHUB_TOKEN }}`                    |\n| `label`                              | no       | `Approved by committers`                                          | Label to be added/removed to the Pull Request if approved/not approved        |\n| `require_committers_approval`        | no       | `true`                                                            | Is approval from user with write permission required                          |\n| `remove_label_when_approval_missing` | no       | `true`                                                            | Should label be removed when approval is missing                              |\n| `comment`                            | no       | `PR approved by at least one committer and no changes requested.` | Add optional comment to the PR when approved (requires label input to be set) |\n| `pullRequestNumber`                  | no       | `${{ steps.source-run-info.outputs.pullRequestNumber }}`          | Pull request number if triggered  by \"worfklow_run\"                           |\n\n## Outputs\n\n| Output         |                              |\n|----------------|------------------------------|\n| `isApproved`   | is Pull Request approved     |\n| `labelSet`     | was label set                |\n| `labelRemoved` | was label removed            |\n\n# Examples\n\n### Workflow Run event\n\n```yaml\nname: \"Label when approved\"\non:\n  workflow_run:\n    workflows: [\"Workflow triggered on pull_request_review\"]\n    types: ['requested']\n\njobs:\n\n  label-when-approved:\n    name: \"Label when approved\"\n    runs-on: ubuntu-latest\n    steps:\n      - name: \"Get information about the original trigger of the run\"\n        uses: potiuk/get-workflow-origin@v1_2\n        id: source-run-info\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n          sourceRunId: ${{ github.event.workflow_run.id }}\n      - name: Label when approved by anyone\n        uses: TobKed/label-when-approved-action@v1.2\n        id: label-when-approved-by-anyone\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n          require_committers_approval: 'true'\n          label: 'Approved by committer'\n          comment: 'PR approved by at least one committer and no changes requested.'\n          pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}\n```\n\n### Pull Request Review event\n\n```yaml\nname: Label when approved\non: pull_request_review\n\njobs:\n\n  label-when-approved:\n    name: \"Label when approved\"\n    runs-on: ubuntu-latest\n    outputs:\n      isApprovedByCommiters: ${{ steps.label-when-approved-by-commiters.outputs.isApproved }}\n      isApprovedByAnyone: ${{ steps.label-when-approved-by-anyone.outputs.isApproved }}\n    steps:\n      - name: Label when approved by commiters\n        uses: TobKed/label-when-approved-action@v1.2\n        id: label-when-approved-by-commiters\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n          label: 'ready to merge (committers)'\n          require_committers_approval: 'true'\n          remove_label_when_approval_missing: 'false'\n          comment: 'PR approved by at least one committer and no changes requested.'\n      - name: Label when approved by anyone\n        uses: TobKed/label-when-approved-action@v1.2\n        id: label-when-approved-by-anyone\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n```\n\n# Development environment\n\nIt is highly recommended tu use [pre commit](https://pre-commit.com). The pre-commits\ninstalled via pre-commit tool handle automatically linting (including automated fixes) as well\nas building and packaging Javascript index.js from the main.ts Typescript code, so you do not have\nto run it yourself.\n\n# License\n[MIT License](LICENSE) covers the scripts and documentation in this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobked%2Flabel-when-approved-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobked%2Flabel-when-approved-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobked%2Flabel-when-approved-action/lists"}