From 0518a3eb333b63600490354025aca4570122c238 Mon Sep 17 00:00:00 2001 From: josephj Date: Mon, 29 Apr 2024 14:32:27 +0200 Subject: [PATCH] Rename check release notes action to check labels and add validation to enforce adding a valid label --- .github/workflows/check_labels.yml | 45 +++++++++++++++++++++++ .github/workflows/check_pr.yml | 1 + .github/workflows/check_release_notes.yml | 35 ------------------ 3 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/check_labels.yml delete mode 100644 .github/workflows/check_release_notes.yml diff --git a/.github/workflows/check_labels.yml b/.github/workflows/check_labels.yml new file mode 100644 index 0000000000..55b1f1de3e --- /dev/null +++ b/.github/workflows/check_labels.yml @@ -0,0 +1,45 @@ +name: Check Labels + +# Every PR should have a label and some labels should include an update to the release notes +on: + pull_request: + branches-ignore: + - 'main' + types: [ synchronize, labeled, unlabeled ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + labels-check: + # https://github.com/actions/virtual-environments/ + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Check PR labels + env: + ALL_PR_LABELS: toJson(github.event.pull_request.labels.*.name) + run: | + echo "$ALL_PR_LABELS" + all_pr_labels= $(jq -r '.[]' <<< $$ALL_PR_LABELS ) + + if [[ "${all_pr_labels[@]}" =~ 'Breaking change' || "${all_pr_labels[@]}" =~ 'Feature' || "${all_pr_labels[@]}" =~ 'Fix' ]] + then + git fetch origin develop --depth 1 + if [ -n "$(git diff origin/develop RELEASE_NOTES.md)" ] + then + echo "RELEASE_NOTES.md was updated" + exit 0 + else + echo "::error::Add release notes for your PR by updating RELEASE_NOTES.md" + exit 1 + fi + elif [[ "${all_pr_labels[@]}" =~ 'Dependencies' || "${all_pr_labels[@]}" =~ 'Chore' ]] + then + echo "No extra actions needed for used labels" + exit 0 + fi + echo "::error::You must add a valid label to this PR" + exit 1 diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml index 8e73cb4e6c..76bdd915e3 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/check_pr.yml @@ -4,6 +4,7 @@ on: pull_request: branches-ignore: - 'main' + - 'develop' types: [ opened, synchronize, reopened ] concurrency: diff --git a/.github/workflows/check_release_notes.yml b/.github/workflows/check_release_notes.yml deleted file mode 100644 index abda5f33fa..0000000000 --- a/.github/workflows/check_release_notes.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Check Release Notes - -# Every PR with a label should include an update to the release notes -on: - pull_request: - branches-ignore: - - 'main' - types: [ synchronize, labeled, unlabeled ] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref }} - cancel-in-progress: true - -jobs: - release-notes-check: - # https://github.com/actions/virtual-environments/ - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Check release notes - if: | - contains(github.event.pull_request.labels.*.name, 'Breaking change') || - contains(github.event.pull_request.labels.*.name, 'Feature') || - contains(github.event.pull_request.labels.*.name, 'Fix') - run: | - git fetch origin develop --depth 1 - if [ -n "$(git diff origin/develop RELEASE_NOTES.md)" ] - then - echo "RELEASE_NOTES.md was updated" - exit 0 - else - echo "::error::Add release notes for your PR by updating RELEASE_NOTES.md" - exit 1 - fi