From 741b303dd9db13fb30bf532998357d29719df76d Mon Sep 17 00:00:00 2001 From: Nikita Korolev <141920865+universal-itengineer@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:36:34 +0300 Subject: [PATCH] chore(ci): fix PR labels detection (#542) * chore(ci): fix the definition of a label for an edition --------- Signed-off-by: Nikita Korolev --- ...dev_module_build-on-self-hosted-runner.yml | 20 +++++++++++++++---- .github/workflows/dev_module_build.yml | 18 ++++++++++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dev_module_build-on-self-hosted-runner.yml b/.github/workflows/dev_module_build-on-self-hosted-runner.yml index e026ae706..afecb136a 100644 --- a/.github/workflows/dev_module_build-on-self-hosted-runner.yml +++ b/.github/workflows/dev_module_build-on-self-hosted-runner.yml @@ -26,7 +26,7 @@ env: on: pull_request: - types: [labeled] + types: [labeled, unlabeled] defaults: run: @@ -57,6 +57,20 @@ jobs: modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} module_edition: ${{ steps.modules_module_tag.outputs.MODULE_EDITION }} steps: + - name: Get Pull Request Labels + id: get-labels + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + }); + return labels.map(label => label.name); + result-encoding: string + - name: Set vars id: modules_module_tag run: | @@ -74,9 +88,7 @@ jobs: echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_OUTPUT" # Slect edition for build, default EE - labels="${{ github.event.pull_request.labels.*.name }}" - - if [[ "$labels" == *"edition/ce"* ]]; then + if echo "${{ steps.get-labels.outputs.result }}" | grep -q "edition/ce"; then echo "MODULE_EDITION=CE" >> $GITHUB_OUTPUT else echo "MODULE_EDITION=EE" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/dev_module_build.yml b/.github/workflows/dev_module_build.yml index a5c87f2e1..77055f259 100644 --- a/.github/workflows/dev_module_build.yml +++ b/.github/workflows/dev_module_build.yml @@ -53,6 +53,20 @@ jobs: modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} module_edition: ${{ steps.modules_module_tag.outputs.MODULE_EDITION }} steps: + - name: Get Pull Request Labels + id: get-labels + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + }); + return labels.map(label => label.name); + result-encoding: string + - name: Set vars id: modules_module_tag run: | @@ -70,9 +84,7 @@ jobs: echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_OUTPUT" # Slect edition for build, default EE - labels="${{ github.event.pull_request.labels.*.name }}" - - if [[ "$labels" == *"edition/ce"* ]]; then + if echo "${{ steps.get-labels.outputs.result }}" | grep -q "edition/ce"; then echo "MODULE_EDITION=CE" >> $GITHUB_OUTPUT else echo "MODULE_EDITION=EE" >> "$GITHUB_OUTPUT"