-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run Prettier to resolve code style issues
- Loading branch information
Showing
2 changed files
with
19 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ jobs: | |
body: comment | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const core = require('@actions/core') | ||
const github = require('@actions/github') | ||
|
||
const assignedIssues = {}; | ||
const assignedIssues = {} | ||
|
||
const main = async () => { | ||
const payload = JSON.parse(core.getInput('payload')); | ||
const payload = JSON.parse(core.getInput('payload')) | ||
|
||
if (payload.action === 'assigned') { | ||
const issue = payload.issue; | ||
assignedIssues[issue.number] = issue.assignee.login; | ||
const issue = payload.issue | ||
assignedIssues[issue.number] = issue.assignee.login | ||
} | ||
|
||
if (payload.action === 'unlabeled' && payload.label.name === 'assigned') { | ||
delete assignedIssues[payload.issue.number]; | ||
delete assignedIssues[payload.issue.number] | ||
} | ||
|
||
if (payload.action === 'opened') { | ||
const pull = payload.pull_request; | ||
const issueNumber = pull.title.split('#')[1]; | ||
const pull = payload.pull_request | ||
const issueNumber = pull.title.split('#')[1] | ||
|
||
if (issueNumber && assignedIssues[issueNumber]) { | ||
const timeDelta = new Date(pull.created_at) - new Date(assignedIssues[issueNumber]); | ||
const timeDelta = | ||
new Date(pull.created_at) - new Date(assignedIssues[issueNumber]) | ||
|
||
const comment = `Time from assignment to PR for #${issueNumber}: ${timeDelta} ms`; | ||
const comment = `Time from assignment to PR for #${issueNumber}: ${timeDelta} ms` | ||
|
||
const octokit = github.getOctokit(core.getInput('github-token')); | ||
const octokit = github.getOctokit(core.getInput('github-token')) | ||
|
||
await octokit.issues.createComment({ | ||
owner: github.context.repo.owner, | ||
repo: github.context.repo.repo, | ||
issue_number: pull.number, | ||
body: comment, | ||
}); | ||
body: comment | ||
}) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
main().catch((error) => { | ||
core.setFailed(error.message); | ||
}); | ||
core.setFailed(error.message) | ||
}) |