Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions .github/workflows/label-community-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,8 @@ jobs:
contents: read

steps:
# Adding this step for debug purposes
# If this works as expected, we can simplify this workflow
# and replace it with the `check-membership` step
- name: Check organization membership (test)
run: echo "${{ github.event.issue.author_association == 'MEMBER' }}"
- name: Check organization membership
id: check-membership
uses: actions/github-script@v7
with:
github-token: ${{ secrets.ORG_MEMBER_READ_TOKEN }}
result-encoding: string
script: |
const issueAuthor = '${{ github.event.issue.user.login }}';
const orgName = 'elastic';

try {
await github.rest.orgs.getMembershipForUser({
org: orgName,
username: issueAuthor
});

console.log(`${issueAuthor} is a member of ${orgName} organization`);
return 'member';

} catch (error) {
if (error.status === 404) {
console.log(`${issueAuthor} is not a member of ${orgName} organization`);
return 'non-member';
} else {
console.log('Error checking organization membership:', error);
return 'error';
}
}

- name: Add community label
if: steps.check-membership.outputs.result == 'non-member'
if: ${{ github.event.issue.author_association != 'MEMBER' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Loading