Skip to content

Commit

Permalink
feat: Add tweet preview to PR conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
IstoraMandiri committed Oct 5, 2022
1 parent 66e7a86 commit 13163d8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 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,8 @@ async function createCheckRun(
process.exit(allTweetsValid ? 0 : 1);
}

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

const response = await octokit.request(
"POST /repos/:owner/:repo/check-runs",
{
Expand All @@ -54,12 +56,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

0 comments on commit 13163d8

Please sign in to comment.