-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
71 lines (62 loc) · 2.55 KB
/
action.yml
File metadata and controls
71 lines (62 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Check External Contributor
description: Checks if PR creator is in a GitHub team and adds a label if not
inputs:
github_team_slug:
description: "GitHub team slug to check membership against (e.g., 'solace-ai')"
required: true
label_name:
description: "Label to add to PR if creator is not in the team"
required: false
default: "external contributor"
github-token:
description: "GitHub token for API access"
required: true
runs:
using: composite
steps:
- name: Check if PR creator is in team
id: check-team
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ inputs.github-token }}
script: |
const teamSlug = '${{ inputs.github_team_slug }}';
const org = context.repo.owner;
const prCreator = context.payload.pull_request.user.login;
console.log(`🔍 Checking team membership for PR creator...`);
console.log(` - Team slug: ${teamSlug}`);
console.log(` - PR creator: ${prCreator}`);
console.log(` - Organization: ${org}`);
try {
const { data } = await github.rest.teams.getMembershipForUserInOrg({
org: org,
team_slug: teamSlug,
username: prCreator
});
core.setOutput('is_member', 'true');
console.log(`✅ PR creator is a member of the team`);
} catch (error) {
if (error.status === 404) {
core.setOutput('is_member', 'false');
console.log(`⚠️ PR creator is not a member of the team`);
} else {
console.log(`⚠️ Could not verify team membership (${error.message}), assuming external contributor`);
core.setOutput('is_member', 'false');
}
}
- name: Add external contributor label
if: steps.check-team.outputs.is_member == 'false'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ inputs.github-token }}
script: |
const labelName = '${{ inputs.label_name }}';
const prNumber = context.issue.number;
console.log(`🏷️ Adding label "${labelName}" to PR #${prNumber}...`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: [labelName]
});
console.log(`✅ Added label "${labelName}" to PR #${prNumber}`);