@@ -24,27 +24,30 @@ jobs:
2424 with :
2525 script : |
2626 try {
27- const { data: membership } = await github.teams.getMembershipForUserInOrg({
27+ const username = context.payload.issue.user.login;
28+ console.log(`Checking membership for user: ${username}`);
29+
30+ // Call GitHub API to check if the user is a member of the team
31+ const membership = await github.teams.getMembershipForUserInOrg({
2832 org: 'patternfly',
2933 team_slug: 'frequent-flyers',
30- username: context.payload.issue.user.login
34+ username: username
3135 });
32- console.log(context.payload.issue.user.login);
33- console.log(membership);
34- if (membership && membership.state === 'active') {
35- core.setOutput('is_team_member', 'true');
36- } else {
37- core.setOutput('is_team_member', 'false');
38- }
36+
37+ console.log(`Membership state: ${membership.data.state}`);
38+
39+ // Return the result as an output
40+ return membership.data.state === 'active' ? { is_team_member: 'true' } : { is_team_member: 'false' };
3941 } catch (error) {
40- // If the user is not a team member, it will throw a 404 error
41- core.setOutput(' is_team_member', 'false');
42+ console.error(`Error checking team membership: ${ error.message}`);
43+ return { is_team_member: 'false' }; // Set false if there's any error
4244 }
45+
4346 - name : Add label if user is a team member
4447 if : steps.check_team_membership.outputs.is_team_member == 'true'
4548 run : |
4649 curl -X POST \
4750 -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
4851 -H "Accept: application/vnd.github.v3+json" \
4952 https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
50- -d '{"labels":["Frequent flyer "]}'
53+ -d '{"labels":["Team Member "]}'
0 commit comments