From c6abdb81f814aacf013f4bb7ae131c693ff07ced Mon Sep 17 00:00:00 2001 From: Kornilios Kourtis Date: Wed, 23 Aug 2023 13:17:08 +0200 Subject: [PATCH] gha: add pr-validation GH action This action validates PRs based on labels. It blocks PRs that have a dont-merge/* label, and blocks PRs that do not have a release-note/* labe. Signed-off-by: Kornilios Kourtis --- .github/workflows/pr-validation.yaml | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/pr-validation.yaml diff --git a/.github/workflows/pr-validation.yaml b/.github/workflows/pr-validation.yaml new file mode 100644 index 00000000000..13ab9c7741f --- /dev/null +++ b/.github/workflows/pr-validation.yaml @@ -0,0 +1,36 @@ +name: pr + +on: + pull_request: + branches: + - main + - v* + types: + - opened + - reopened + - synchronize + - edited + - ready_for_review + - labeled + - unlabeled + +env: + LABELS: ${{ join(github.event.pull_request.labels.*.name, ' ') }} + +jobs: + # based on https://github.com/WordPress/performance/blob/trunk/.github/workflows/pr-validation.yml + labels: + name: validate labels + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: release-note/* + if: always() && !contains(env.LABELS, 'release-note/') + run: | + echo "please add a release-note/* label to the pull request" + exit 1 + - name: dont-merge/* + if: always() && contains(env.LABELS, 'dont-merge/') + run: | + echo "pull request has a dont-merge label" + exit 1