Skip to content

Commit

Permalink
feat: Add pull_request.user.login (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris authored Sep 14, 2020
1 parent ffd089d commit 0cbed3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/label-commenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
ref: master

- name: Label Commenter
uses: peaceiris/[email protected].0
uses: peaceiris/[email protected].1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# config_file: .github/label-commenter-config.yml
35 changes: 26 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,33 @@ export async function run(): Promise<void> {
}

// Render template
const commentBodyView = {
issue: {
user: {
login: (context.payload as any).issue.user.login // eslint-disable-line @typescript-eslint/no-explicit-any
}
},
sender: {
login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any
const commentBodyView = (() => {
if (eventName === 'issues') {
return {
issue: {
user: {
login: (context.payload as any).issue.user.login // eslint-disable-line @typescript-eslint/no-explicit-any
}
},
sender: {
login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any
}
};
} else if (eventName === 'pull_request' || eventName === 'pull_request_target') {
return {
pull_request: {
user: {
login: (context.payload as any).pull_request.user.login // eslint-disable-line @typescript-eslint/no-explicit-any
}
},
sender: {
login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any
}
};
} else {
return {};
}
};
})();
const commentBodyRendered = Mustache.render(commentBody, commentBodyView);

// Post comment
Expand Down

0 comments on commit 0cbed3c

Please sign in to comment.