Skip to content

Commit 2cce346

Browse files
committed
chore: require org membership
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent d62e280 commit 2cce346

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

.github/workflows/slash_commands.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -298,27 +298,25 @@ jobs:
298298
const targetOwner = 'stdlib-js';
299299
const targetRepo = ( stdlibTarget === 'private' ) ? 'todo' : 'stdlib';
300300
301-
// For private repo targets, verify the commenter is an org member:
302-
if ( stdlibTarget === 'private' ) {
303-
const commenter = context.payload.comment.user.login;
304-
try {
305-
await github.rest.orgs.checkMembershipForUser({
306-
'org': targetOwner,
307-
'username': commenter
308-
});
309-
} catch ( err ) {
310-
console.log( 'Error checking org membership: %s', err.message );
311-
const lines = commentBody.split( '\n' );
312-
const quote = lines.map( line => `> ${line}` ).join( '\n' );
313-
await github.rest.issues.createComment({
314-
'owner': context.repo.owner,
315-
'repo': context.repo.repo,
316-
'issue_number': context.issue.number,
317-
'body': `${quote}\n\n@${commenter}, you must be a member of the \`${targetOwner}\` organization to create issues on the private todo repository.`
318-
});
319-
core.setFailed( `User ${commenter} is not a member of ${targetOwner}.` );
320-
return;
321-
}
301+
// Verify the commenter is an org member:
302+
const commenter = context.payload.comment.user.login;
303+
try {
304+
await github.rest.orgs.checkMembershipForUser({
305+
'org': targetOwner,
306+
'username': commenter
307+
});
308+
} catch ( err ) {
309+
console.log( 'Error checking org membership: %s', err.message );
310+
const lines = commentBody.split( '\n' );
311+
const quote = lines.map( line => `> ${line}` ).join( '\n' );
312+
await github.rest.issues.createComment({
313+
'owner': context.repo.owner,
314+
'repo': context.repo.repo,
315+
'issue_number': context.issue.number,
316+
'body': `${quote}\n\n@${commenter}, you must be a member of the \`${targetOwner}\` organization to use the \`/stdlib todo\` command.`
317+
});
318+
core.setFailed( `User ${commenter} is not a member of ${targetOwner}.` );
319+
return;
322320
}
323321
324322
// Build issue creation parameters:
@@ -329,7 +327,7 @@ jobs:
329327
};
330328
// Build provenance footer:
331329
const prUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/pull/${context.issue.number}`;
332-
const provenance = `\n\n---\n*Created via \`/stdlib todo\` from [${context.repo.owner}/${context.repo.repo}#${context.issue.number}](${prUrl}) by @${context.payload.comment.user.login}.*`;
330+
const provenance = `\n\n---\n*Created via \`/stdlib todo\` from [${context.repo.owner}/${context.repo.repo}#${context.issue.number}](${prUrl}) by @${commenter}.*`;
333331
334332
if ( body ) {
335333
issueParams.body = body + provenance;
@@ -349,8 +347,8 @@ jobs:
349347
350348
// Post a confirmation comment:
351349
const confirmBody = droppedLabels.length > 0
352-
? `@${context.payload.comment.user.login}, the following todo issue has been created: ${issue.data.html_url}\n\n> [!WARNING]\n> The following labels were not applied because they do not exist on \`${targetOwner}/${targetRepo}\`: ${droppedLabels.map( l => `\`${l}\`` ).join( ', ' )}.`
353-
: `@${context.payload.comment.user.login}, the following todo issue has been created: ${issue.data.html_url}`;
350+
? `@${commenter}, the following todo issue has been created: ${issue.data.html_url}\n\n> [!WARNING]\n> The following labels were not applied because they do not exist on \`${targetOwner}/${targetRepo}\`: ${droppedLabels.map( l => `\`${l}\`` ).join( ', ' )}.`
351+
: `@${commenter}, the following todo issue has been created: ${issue.data.html_url}`;
354352
await github.rest.issues.createComment({
355353
'owner': context.repo.owner,
356354
'repo': context.repo.repo,

0 commit comments

Comments
 (0)