forked from jwalton/gh-find-current-pr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
24 lines (19 loc) · 855 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const core = require('@actions/core');
const { GitHub, context } = require('@actions/github');
async function main() {
const token = core.getInput('github-token', { required: true });
const sha = core.getInput('sha');
const client = new GitHub(token, {});
const result = await client.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: sha || context.sha,
});
const pr = result.data.length > 0 && result.data[0];
core.setOutput('pr', pr && pr.number || '');
core.setOutput('number', pr && pr.number || '');
core.setOutput('title', pr && pr.title || '');
core.setOutput('body', pr && pr.body || '');
core.setOutput('ready', (pr && pr.draft === false && 'true') || 'false');
}
main().catch(err => core.setFailed(err.message));