From 841f971bed3a4e9543e5746b6233e4056de56d51 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 27 Jan 2020 23:37:51 +0000 Subject: [PATCH] build(release): compiled action for 1.4.1 [skip ci] --- dist/index.js | 83 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/dist/index.js b/dist/index.js index cf83e4c5..f133c5f9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7568,42 +7568,70 @@ module.exports = createCheckRun; const { autoLink } = __webpack_require__(914); -function createCheckRun({ octokit, payload, startedAt }, newTweets) { +async function createCheckRun( + { octokit, payload, startedAt, toolkit }, + newTweets +) { const allTweetsValid = newTweets.every(tweet => tweet.valid); - return octokit.request("POST /repos/:owner/:repo/check-runs", { - headers: { - accept: "application/vnd.github.antiope-preview+json" - }, - owner: payload.repository.owner.login, - repo: payload.repository.name, - name: "preview", - head_sha: payload.pull_request.head.sha, - started_at: startedAt, - completed_at: new Date().toISOString(), - status: "completed", - conclusion: allTweetsValid ? "success" : "failure", - output: { - title: `${newTweets.length} tweet(s)`, - summary: newTweets - .map(tweet => { - const text = autoLink(tweet.text).replace(/(^|\n)/g, "$1> "); - - if (tweet.valid) { - return `### ✅ Valid + // Check runs cannot be created if the pull request was created by a fork, + // so we just log out the result. + // https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token#permissions-for-the-github_token + if (payload.pull_request.head.repo.fork) { + for (const tweet of newTweets) { + if (tweet.valid) { + toolkit.info(`### ✅ Valid + +${tweet.text}`); + } else { + toolkit.info(`### ❌ Invalid + +${tweet.text} + +The above tweet is ${tweet.weightedLength - 280} characters too long`); + } + } + process.exit(allTweetsValid ? 0 : 1); + } + + const response = await octokit.request( + "POST /repos/:owner/:repo/check-runs", + { + headers: { + accept: "application/vnd.github.antiope-preview+json" + }, + owner: payload.repository.owner.login, + repo: payload.repository.name, + name: "preview", + head_sha: payload.pull_request.head.sha, + started_at: startedAt, + completed_at: new Date().toISOString(), + status: "completed", + conclusion: allTweetsValid ? "success" : "failure", + output: { + title: `${newTweets.length} tweet(s)`, + summary: newTweets + .map(tweet => { + const text = autoLink(tweet.text).replace(/(^|\n)/g, "$1> "); + + if (tweet.valid) { + return `### ✅ Valid ${text}`; - } + } - return `### ❌ Invalid + return `### ❌ Invalid ${text} The above tweet is ${tweet.weightedLength - 280} characters too long`; - }) - .join("\n\n---\n\n") + }) + .join("\n\n---\n\n") + } } - }); + ); + + toolkit.info(`check run created: ${response.data.html_url}`); } @@ -36752,8 +36780,7 @@ async function handlePullRequest(state) { }); const newTweets = await getNewTweets(state); - const response = await createCheckRun(state, newTweets); - toolkit.info(`check run created: ${response.data.html_url}`); + await createCheckRun(state, newTweets); }