Skip to content

Commit 38e670e

Browse files
author
Bot
committed
get pull request body
1 parent 58fee87 commit 38e670e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

actions/add-code-submission-to-db.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@ const main = async () => {
1010

1111
const { context } = github;
1212

13-
console.log(`Commit: "${context.sha}`);
14-
console.log(JSON.stringify(context));
13+
console.log(`Commit: "${context.sha}"`);
1514

16-
const octokit = github.getOctokit(process.env.TOKEN);
15+
let prBody;
1716

18-
const { data } = await octokit.repos.listPullRequestsAssociatedWithCommit({
19-
owner: context.repo.owner,
20-
repo: context.repo.repo,
21-
commit_sha: context.sha,
22-
});
17+
if (context.pull_request) {
18+
prBody = context.pull_request.body;
19+
} else {
20+
const octokit = github.getOctokit(process.env.TOKEN);
2321

24-
const prBody = data[0].body;
22+
const { data } = await octokit.repos.listPullRequestsAssociatedWithCommit({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
commit_sha: context.sha,
26+
});
27+
28+
prBody = data[0].body;
29+
}
2530

2631
core.endGroup();
2732

0 commit comments

Comments
 (0)