Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/pull-request/create-check-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ async function createCheckRun(
process.exit(allTweetsValid ? 0 : 1);
}

const summary = parsedTweets
.map((tweet) => tweetToCheckRunSummary(tweet))
.join("\n\n---\n\n");

const response = await octokit.request(
"POST /repos/:owner/:repo/check-runs",
{
Expand All @@ -54,12 +58,20 @@ async function createCheckRun(
conclusion: allTweetsValid ? "success" : "failure",
output: {
title: `${parsedTweets.length} tweet(s)`,
summary: parsedTweets.map(tweetToCheckRunSummary).join("\n\n---\n\n"),
summary,
},
}
);

toolkit.info(`check run created: ${response.data.html_url}`);

// post preview to the PR conversation
await octokit.rest.issues.createComment({
owner: payload.repository.owner.login,
repo: payload.repository.name,
issue_number: payload.pull_request.number,
body: `## Added ${parsedTweets.length} tweet(s)\n\n${summary}`,
});
}

function tweetToCheckRunSummary(tweet) {
Expand Down