Skip to content

Commit

Permalink
Type variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav-yadav committed May 26, 2023
1 parent 4a2d2dc commit 43886ae
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import * as core from '@actions/core';
import * as github from '@actions/github';

/**
* Check if the issue is marked as needing attention, and this comment's
* author is the original issue author.
*/
async function run() {
*/
async function run(): Promise<void> {
try {
const octokit = github.getOctokit(core.getInput('token'), {required: true});
const context = github.context;
const {owner, repo} = context.repo;
const {issue, comment} = context.payload;
const labels = issue?.labels;
const issue_number: number = issue?.number as number;
const issue_number = Number(issue?.number);

const responseRequiredLabel = core.getInput('response-required-label');
const needsAttentionLabel = core.getInput('needs-attention-label');
const perform = core.getInput('perform');
const responseRequiredLabel: string = core.getInput(
'response-required-label',
);
const needsAttentionLabel: string = core.getInput('needs-attention-label');
const perform: string = core.getInput('perform');

const isMarked = labels
.map(label => label.name)
const isMarked: boolean = labels
.map(label => label.name as string)
.includes(responseRequiredLabel);

if (isMarked && issue?.user.login === comment?.user.login) {
if (perform) {
console.log(`[Actions:needs-attention]: ${owner}/${repo}#${issue_number} needs attention`);
console.log(
`[Actions:needs-attention]: ${owner}/${repo}#${issue_number} needs attention`,
);
await octokit.rest.issues.removeLabel({
owner,
repo,
Expand Down Expand Up @@ -53,8 +57,8 @@ async function run() {
`${owner}/${repo}#${issue_number} does not need attention`,
);
}
} catch (error: any) {
core.setFailed(error.message);
} catch (error) {
if (error instanceof Error) core.setFailed(error.message);
}
}

Expand Down

0 comments on commit 43886ae

Please sign in to comment.