Skip to content

Commit

Permalink
chore(ci): fix PR labels detection (#542)
Browse files Browse the repository at this point in the history
* chore(ci): fix the definition of a label for an edition

---------

Signed-off-by: Nikita Korolev <[email protected]>
  • Loading branch information
universal-itengineer authored Nov 28, 2024
1 parent c4c9927 commit 741b303
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/dev_module_build-on-self-hosted-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:

on:
pull_request:
types: [labeled]
types: [labeled, unlabeled]

defaults:
run:
Expand Down Expand Up @@ -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: |
Expand All @@ -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"
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/dev_module_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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"
Expand Down

0 comments on commit 741b303

Please sign in to comment.