From 69461684ed74b408e3b5173707956f2d46d59eca Mon Sep 17 00:00:00 2001 From: Merel Theisen Date: Thu, 31 Oct 2024 13:59:45 +0000 Subject: [PATCH 1/5] Add GH action to automatically label community issues Signed-off-by: Merel Theisen --- .github/workflows/label-community-issues.yml | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/label-community-issues.yml diff --git a/.github/workflows/label-community-issues.yml b/.github/workflows/label-community-issues.yml new file mode 100644 index 0000000000..1e69d71f7e --- /dev/null +++ b/.github/workflows/label-community-issues.yml @@ -0,0 +1,35 @@ +name: Label Community Issues + +on: + issues: + types: [opened] + +jobs: + label_external_issues: + runs-on: ubuntu-latest + steps: + - name: Check if issue author is a member + id: check_author + uses: actions/github-script@v6 + with: + script: | + const { owner, repo } = context.repo; + const issueAuthor = context.payload.issue.user.login; + + // Check if the issue author is a member of the org + const { data: membership } = await github.orgs.getMembershipForUser({ + org: owner, + username: issueAuthor + }).catch(() => ({ data: null })); + + // Set an output for the membership status + return membership ? 'internal' : 'external'; + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Label issue if author is external + if: steps.check_author.outputs.result == 'external' + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'Community' From 66fdaee851c1de4275e233ca87078be415d61826 Mon Sep 17 00:00:00 2001 From: Merel Theisen Date: Thu, 31 Oct 2024 16:34:37 +0000 Subject: [PATCH 2/5] Test action Signed-off-by: Merel Theisen --- .github/workflows/label-community-issues.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/label-community-issues.yml b/.github/workflows/label-community-issues.yml index 1e69d71f7e..1578f8139e 100644 --- a/.github/workflows/label-community-issues.yml +++ b/.github/workflows/label-community-issues.yml @@ -1,34 +1,37 @@ name: Label Community Issues on: + pull_request_target: + types: + - opened issues: - types: [opened] + types: + - opened jobs: label_external_issues: runs-on: ubuntu-latest steps: - - name: Check if issue author is a member + - name: Check if issue author is a member of Kedro org id: check_author uses: actions/github-script@v6 with: script: | - const { owner, repo } = context.repo; const issueAuthor = context.payload.issue.user.login; // Check if the issue author is a member of the org const { data: membership } = await github.orgs.getMembershipForUser({ - org: owner, + org: "kedro-org", username: issueAuthor }).catch(() => ({ data: null })); - + console.log(data) // Set an output for the membership status return membership ? 'internal' : 'external'; env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Label issue if author is external - if: steps.check_author.outputs.result == 'external' + if: steps.check_author.outputs.result == 'internal' uses: actions-ecosystem/action-add-labels@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} From 7af40ffe8fba804c8860c46bcf3d78b2739630df Mon Sep 17 00:00:00 2001 From: Merel Theisen Date: Thu, 31 Oct 2024 16:44:13 +0000 Subject: [PATCH 3/5] Undo test stuf Signed-off-by: Merel Theisen --- .github/workflows/label-community-issues.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/label-community-issues.yml b/.github/workflows/label-community-issues.yml index 1578f8139e..d3b30d7494 100644 --- a/.github/workflows/label-community-issues.yml +++ b/.github/workflows/label-community-issues.yml @@ -1,9 +1,6 @@ name: Label Community Issues on: - pull_request_target: - types: - - opened issues: types: - opened @@ -31,7 +28,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Label issue if author is external - if: steps.check_author.outputs.result == 'internal' + if: steps.check_author.outputs.result == 'external' uses: actions-ecosystem/action-add-labels@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} From 55b2762955361c702df12fb9ee54239bac36626e Mon Sep 17 00:00:00 2001 From: Merel Theisen Date: Fri, 1 Nov 2024 10:44:53 +0000 Subject: [PATCH 4/5] Update label action Signed-off-by: Merel Theisen --- .github/workflows/label-community-issues.yml | 40 ++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/label-community-issues.yml b/.github/workflows/label-community-issues.yml index d3b30d7494..b4f965fa5d 100644 --- a/.github/workflows/label-community-issues.yml +++ b/.github/workflows/label-community-issues.yml @@ -6,29 +6,39 @@ on: - opened jobs: - label_external_issues: + label: runs-on: ubuntu-latest steps: - name: Check if issue author is a member of Kedro org - id: check_author uses: actions/github-script@v6 + id: membership with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string script: | - const issueAuthor = context.payload.issue.user.login; - // Check if the issue author is a member of the org - const { data: membership } = await github.orgs.getMembershipForUser({ - org: "kedro-org", - username: issueAuthor - }).catch(() => ({ data: null })); - console.log(data) - // Set an output for the membership status - return membership ? 'internal' : 'external'; - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + try { + const result = await github.rest.orgs.getMembershipForUser({ + org: "kedro-org", + username: '${{ github.actor }}' + }) - - name: Label issue if author is external - if: steps.check_author.outputs.result == 'external' + console.log(result?.data?.state) + if (result?.data?.state == "active"){ + console.log("%s: detected as an active member of elastic org", '${{ github.actor }}') + return "member"; + } else { + console.log("%s: not detected as active member of elastic org", '${{ github.actor }}') + return "notMember"; + } + + } catch (error) { + return "notMember"; + } + + + - name: Label issue if author is from community + if: ${{ steps.membership.outputs.result == 'notMember' }} uses: actions-ecosystem/action-add-labels@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} From a1ff388ca599db49a5a553bce835a5b86e36c09b Mon Sep 17 00:00:00 2001 From: Merel Theisen Date: Fri, 1 Nov 2024 10:45:29 +0000 Subject: [PATCH 5/5] Update label action Signed-off-by: Merel Theisen --- .github/workflows/label-community-issues.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/label-community-issues.yml b/.github/workflows/label-community-issues.yml index b4f965fa5d..191d4e55c0 100644 --- a/.github/workflows/label-community-issues.yml +++ b/.github/workflows/label-community-issues.yml @@ -25,10 +25,10 @@ jobs: console.log(result?.data?.state) if (result?.data?.state == "active"){ - console.log("%s: detected as an active member of elastic org", '${{ github.actor }}') + console.log("%s: detected as an active member of Kedro org", '${{ github.actor }}') return "member"; } else { - console.log("%s: not detected as active member of elastic org", '${{ github.actor }}') + console.log("%s: not detected as active member of Kedro org", '${{ github.actor }}') return "notMember"; }