Skip to content

Commit

Permalink
feat: Add issue.assignees (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris authored Jun 21, 2020
1 parent 2728246 commit 2e5a65a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/label-commenter-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ labels:
issue:
body: |
Thank you @{{ sender.login }} for suggesting this.
The maintainer will reply.
The maintainers will reply.
{{#issue.assignees}}
- @{{.}}
{{/issue.assignees}}
17 changes: 16 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {getInputs} from './get-inputs';
import fs from 'fs';
import yaml from 'js-yaml';
import Mustache from 'mustache';
import {stringify} from 'querystring';

async function closeIssue(
githubClient: InstanceType<typeof GitHub>,
Expand Down Expand Up @@ -126,16 +127,29 @@ export async function run(): Promise<void> {
}

// Render template
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const assignees = (context.payload as any).issue.assignees;
if (core.isDebug()) {
console.log((context.payload as any).issue.assignees); // eslint-disable-line @typescript-eslint/no-explicit-any
console.log(assignees);
}
const commentBodyView = {
sender: {
login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any
},
issue: {
assignees: function () {
const assigneesList: string[] = [];
Object.keys(assignees).forEach(assignee => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assigneesList.push((assignee as any).login);
});
return assigneesList;
}
}
};
const commentBodyRendered = Mustache.render(commentBody, commentBodyView);

// Post comment
const githubToken = inps.GithubToken;
const githubClient = getOctokit(githubToken);
await githubClient.issues.createComment({
Expand All @@ -145,6 +159,7 @@ export async function run(): Promise<void> {
body: commentBodyRendered
});

// Close or Open issue
if (finalAction === 'close') {
await closeIssue(githubClient, issueNumber);
} else if (finalAction === 'open') {
Expand Down

0 comments on commit 2e5a65a

Please sign in to comment.