diff options
author | Jack <87339414+algojack@users.noreply.github.com> | 2022-02-22 12:18:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 12:18:53 -0500 |
commit | b4666bd63ad46c4211287768f4b4a7a1353c2a9c (patch) | |
tree | a50332ac63d82600efeea085e2e1829870981565 | |
parent | bc5f22c50e476248159929766aebd835e31ea8d2 (diff) |
CICD: Adding PR Type label checker (#3645)
We want to make PR Type labels required on PRs. This is a github action that will check for us if a correct label has been added"
Tested on this PR. Feel free to test it here too by adding a label or removing it.
-rw-r--r-- | .github/workflows/pr-type-category.yml | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/.github/workflows/pr-type-category.yml b/.github/workflows/pr-type-category.yml new file mode 100644 index 000000000..6f08d2862 --- /dev/null +++ b/.github/workflows/pr-type-category.yml @@ -0,0 +1,35 @@ +name: Check PR category and type +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled, edited] +jobs: + check_label: + runs-on: ubuntu-latest + name: Check PR Category and Type + steps: + - name: "Failed to find proper PR Type label. Please add one of the following: 'New Feature', 'Enhancement', or 'Bug-Fix'" + run: exit 1 + if: | + !contains(github.event.pull_request.labels.*.name, 'New Feature') && + !contains(github.event.pull_request.labels.*.name, 'Enhancement') && + !contains(github.event.pull_request.labels.*.name, 'Bug-Fix') + - name: "Found more than one PR Type label. Please add only one of the following: 'New Feature', 'Enhancement', or 'Bug-Fix'" + run: exit 1 + if: | + ( + contains(github.event.pull_request.labels.*.name, 'New Feature') && + contains(github.event.pull_request.labels.*.name, 'Enhancement') + ) || ( + contains(github.event.pull_request.labels.*.name, 'New Feature') && + contains(github.event.pull_request.labels.*.name, 'Bug-Fix') + ) || ( + contains(github.event.pull_request.labels.*.name, 'Enhancement') && + contains(github.event.pull_request.labels.*.name, 'Bug-Fix') + ) + - name: "PR Category is missing from PR title. Please add it like '<category>: <pr title>'" + run: | + if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then + exit 1 + fi + - name: "Found at least one PR Type label and Category in the title. Good job!" + run: exit 0 |