Skip to content

Commit 257c3f8

Browse files
authored
Enable preview builds for forks (#79648)
1 parent 1f25118 commit 257c3f8

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ jobs:
532532
path: crates/wasm
533533

534534
- name: Create tarballs
535-
run: node scripts/create-preview-tarballs.js "${{ github.sha }}" "${{ runner.temp }}/preview-tarballs"
535+
run: node scripts/create-preview-tarballs.js "${{ github.sha }}" "${{ github.workflow_sha }}" "${{ runner.temp }}/preview-tarballs"
536536

537537
- name: Upload tarballs
538538
uses: actions/upload-artifact@v4

scripts/create-preview-tarballs.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ const path = require('node:path')
66

77
async function main() {
88
const [
9-
commitSha,
9+
githubSha,
10+
githubWorkflowSha,
1011
tarballDirectory = path.join(os.tmpdir(), 'vercel-nextjs-preview-tarballs'),
1112
] = process.argv.slice(2)
1213
const repoRoot = path.resolve(__dirname, '..')
1314

1415
await fs.mkdir(tarballDirectory, { recursive: true })
1516

1617
const [{ stdout: shortSha }, { stdout: dateString }] = await Promise.all([
17-
execa('git', ['rev-parse', '--short', commitSha]),
18+
execa('git', ['rev-parse', '--short', githubSha]),
1819
// Source: https://github.com/facebook/react/blob/767f52237cf7892ad07726f21e3e8bacfc8af839/scripts/release/utils.js#L114
1920
execa(`git`, [
2021
'show',
2122
'-s',
2223
'--no-show-signature',
2324
'--format=%cd',
2425
'--date=format:%Y%m%d',
25-
commitSha,
26+
githubSha,
2627
]),
2728
])
2829

@@ -97,16 +98,18 @@ async function main() {
9798
])
9899
const packages = JSON.parse(lernaListJson.stdout)
99100
const packagesByVersion = new Map()
101+
// vercel-packages finds GH artifacts via the head SHA because that's the only
102+
// API GitHub offers.
100103
for (const packageInfo of packages) {
101104
packagesByVersion.set(
102105
packageInfo.name,
103-
`https://vercel-packages.vercel.app/next/commits/${commitSha}/${packageInfo.name}`
106+
`https://vercel-packages.vercel.app/next/commits/${githubWorkflowSha}/${packageInfo.name}`
104107
)
105108
}
106109
for (const nextSwcPackageName of nextSwcPackageNames) {
107110
packagesByVersion.set(
108111
nextSwcPackageName,
109-
`https://vercel-packages.vercel.app/next/commits/${commitSha}/${nextSwcPackageName}`
112+
`https://vercel-packages.vercel.app/next/commits/${githubWorkflowSha}/${nextSwcPackageName}`
110113
)
111114
}
112115

0 commit comments

Comments
 (0)