Skip to content

Github action to make sure a PR label is unique across all PR

License

Notifications You must be signed in to change notification settings

stephdotnet/unique-labels

Repository files navigation

Unique PR labels

CI Check dist/ CodeQL Coverage

This action ensures that a pull request label is applied to only one pull request at a time. When you apply a unique label to a PR, this action will automatically remove it from any other PR currently labeled with it.

This can be helpful when using labels to trigger deployments or builds without having to manually unlabel previous PRs.

Setting up action

Create a .github/workflows/unique-labels.yml

on:
  pull_request:
    types: [opened, edited]

name: unique-pr-labels
jobs:
  label:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: stephdotnet/unique-labels@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          labels: "["label-one", "label-two"]"

Contributing

The following options allow you to test the action live (using local-action or act) or using jest. In any cases you'll have to run all the tests before submitting the PR (jest + lint)

  • Run npm install
  • Make the changes
  • Run npm run all
  • Open a pull request

Running the action live (using local action)

  • Create the .env file from .env.example
    • Set a value for INPUT_TOKEN (Github PAT)
  • Run npm install
  • Make the changes
  • Run local-action run ./ src/index.ts .env (if you're using https://github.com/github/local-action)

Running the action live (using act)

  • Install nektos/act
  • Create the .actrc file from .actrc.example
    • Set a value for token (Github PAT)
  • Run act

Running tests

  • Run npm install
  • Make the changes
  • Run npm run test

| All api calls are mocked and test contexts/fixtures available in the __tests__/fixtures folder

About

Github action to make sure a PR label is unique across all PR

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published