Unverified Commit 4e6beadc authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Use commit-based tarball URL in PR stats comment (#90709)

The previous method of using the PR endpoint under the hood calls the
GitHub API to get the commit SHA, which is a waste of resources, so just
use the commit SHA directly in the tarball URL.
parent 1cc74578
...@@ -974,16 +974,13 @@ function generateDiffsSection(result) { ...@@ -974,16 +974,13 @@ function generateDiffsSection(result) {
} }
function generatePrTarballSection(actionInfo) { function generatePrTarballSection(actionInfo) {
if (actionInfo.isRelease || !actionInfo.issueId) return '' if (actionInfo.isRelease || !actionInfo.githubHeadSha) return ''
const prNumber = String(actionInfo.issueId).trim()
if (!/^\d+$/.test(prNumber)) return ''
return `<details> return `<details>
<summary><strong>📎 Tarball URL</strong></summary> <summary><strong>📎 Tarball URL</strong></summary>
\`\`\` \`\`\`
next@https://vercel-packages.vercel.app/next/prs/${prNumber}/next https://vercel-packages.vercel.app/next/commits/${actionInfo.githubHeadSha}/next
\`\`\` \`\`\`
</details> </details>
......
...@@ -8,6 +8,7 @@ module.exports = function actionInfo() { ...@@ -8,6 +8,7 @@ module.exports = function actionInfo() {
ISSUE_ID, ISSUE_ID,
SKIP_CLONE, SKIP_CLONE,
GITHUB_REF, GITHUB_REF,
GITHUB_SHA,
LOCAL_STATS, LOCAL_STATS,
GIT_ROOT_DIR, GIT_ROOT_DIR,
GITHUB_ACTION, GITHUB_ACTION,
...@@ -55,6 +56,9 @@ module.exports = function actionInfo() { ...@@ -55,6 +56,9 @@ module.exports = function actionInfo() {
prRef: GITHUB_REF, prRef: GITHUB_REF,
isLocal: LOCAL_STATS, isLocal: LOCAL_STATS,
commitId: null, commitId: null,
// Mirrors github.event.after || github.sha used by build_and_deploy.yml
// to ensure the tarball URL matches the deployed artifact.
githubHeadSha: GITHUB_SHA || null,
issueId: ISSUE_ID, issueId: ISSUE_ID,
isRelease: isRelease:
GITHUB_REPOSITORY === 'vercel/next.js' && GITHUB_REPOSITORY === 'vercel/next.js' &&
...@@ -70,6 +74,10 @@ module.exports = function actionInfo() { ...@@ -70,6 +74,10 @@ module.exports = function actionInfo() {
const event = require(GITHUB_EVENT_PATH) const event = require(GITHUB_EVENT_PATH)
info.actionName = event.action || info.actionName info.actionName = event.action || info.actionName
if (event.after) {
info.githubHeadSha = event.after
}
if (releaseTypes.has(info.actionName)) { if (releaseTypes.has(info.actionName)) {
info.isRelease = true info.isRelease = true
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment