@@ -18,39 +18,24 @@ jobs:
1818 label-issue :
1919 runs-on : ubuntu-latest
2020 steps :
21- - name : Check if the author is on the team
22- id : check_team_membership
23- uses : actions/github-script@v6
24- with :
25- script : |
26- const { Octokit } = require("@octokit/core");
27- const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
28-
29- try {
30- const username = context.payload.issue.user.login;
31- console.log(`Checking membership for user: ${username}`);
32-
33- // List all members of the team and check if the user is one of them
34- const { data: members } = await octokit.request('GET /orgs/{org}/teams/{team_slug}/members', {
35- org: 'patternfly',
36- team_slug: 'frequent-flyers',
37- });
38-
39- const isTeamMember = members.some(member => member.login === username);
40-
41- console.log(`User is ${isTeamMember ? '' : 'not '}a member of the team.`);
21+ - name : Team Membership Checker
22+ # You may pin to the exact commit or the version.
23+ # uses: TheModdingInquisition/actions-team-membership@a69636a92bc927f32c3910baac06bacc949c984c
24+ uses :
TheModdingInquisition/[email protected] 25+ with :
26+ # Repository token. GitHub Action token is used by default(recommended). But you can also use the other token(e.g. personal access token).
27+ token : ${{ secrets.GH_READ_ORG_TOKEN }}
28+ # The team to check for.
29+ team : ' frequent-flyers'
30+ # The organization of the team to check for. Defaults to the context organization.
31+ organization : ' patternfly'
32+ # If the action should exit if the user is not part of the team.
33+ exit : true
4234
43- return { is_team_member: isTeamMember ? 'true' : 'false' };
44- } catch (error) {
45- console.error(`Error checking team membership: ${error.message}`);
46- return { is_team_member: 'false' };
47- }
48-
49- - name : Add label if user is a team member
50- if : steps.check_team_membership.outputs.is_team_member == 'true'
51- run : |
52- curl -X POST \
53- -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
54- -H "Accept: application/vnd.github.v3+json" \
55- https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
56- -d '{"labels":["Team Member"]}'
35+ - name : Add label if user is a team member
36+ run : |
37+ curl -X POST \
38+ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
39+ -H "Accept: application/vnd.github.v3+json" \
40+ https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
41+ -d '{"labels":["Frequent flyer"]}'
0 commit comments