Skip to content

Commit

Permalink
factor out common props for issue rest calls
Browse files Browse the repository at this point in the history
  • Loading branch information
naseemkullah committed Aug 15, 2021
1 parent 46d00ce commit 5c1b0cf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ async function run() {

const lsfFiles = largeFiles.concat(accidentallyCheckedInLsfFiles);

const issueBaseProps = {
...repo,
issue_number: pullRequestNumber
};

if (lsfFiles.length > 0) {
core.info('Detected file(s) that should be in LFS:');
core.info(String(lsfFiles));
Expand All @@ -125,14 +130,12 @@ async function run() {
}`;

await octokit.rest.issues.addLabels({
...repo,
issue_number: pullRequestNumber,
...issueBaseProps,
labels: [labelName],
});

await octokit.rest.issues.createComment({
...repo,
issue_number: pullRequestNumber,
...issueBaseProps,
body,
});

Expand All @@ -144,13 +147,11 @@ async function run() {
core.info('No large file(s) detected...');

const {data: labels} = await octokit.rest.issues.listLabelsOnIssue({
...repo,
issue_number: 1,
...issueBaseProps,
});
if (labels.map(l => l.name).includes(labelName)) {
await octokit.rest.issues.removeLabel({
...repo,
issue_number: 1,
...issueBaseProps,
name: labelName,
});
core.info(`label ${labelName} removed`);
Expand Down

0 comments on commit 5c1b0cf

Please sign in to comment.