Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
264d7962
Unverified
Commit
264d7962
authored
Jul 16, 2026
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Jul 16, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[16.x][ci] Allow configuring the base URL for preview builds (#95829)
parent
6734ad3d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
68 additions
and
10 deletions
+68
-10
add-comment.js
.github/actions/next-stats-action/src/add-comment.js
+1
-1
action-info.js
.github/actions/next-stats-action/src/prepare/action-info.js
+3
-0
build_and_deploy.yml
.github/workflows/build_and_deploy.yml
+1
-1
build_and_test.yml
.github/workflows/build_and_test.yml
+8
-4
build_reusable.yml
.github/workflows/build_reusable.yml
+3
-0
pull_request_stats.yml
.github/workflows/pull_request_stats.yml
+1
-0
test_e2e_deploy_release.yml
.github/workflows/test_e2e_deploy_release.yml
+3
-0
create-preview-tarballs.js
scripts/create-preview-tarballs.js
+4
-2
test-new-tests.mjs
scripts/test-new-tests.mjs
+12
-2
next-deploy.ts
test/lib/next-modes/next-deploy.ts
+32
-0
No files found.
.github/actions/next-stats-action/src/add-comment.js
View file @
264d7962
...
...
@@ -980,7 +980,7 @@ function generatePrTarballSection(actionInfo) {
<summary><strong>📎 Tarball URL</strong></summary>
\`\`\`
https://vercel-packages.vercel.app/next
/commits/
${
actionInfo
.
githubHeadSha
}
/next
${
actionInfo
.
previewBuildsBaseUrl
}
/commits/
${
actionInfo
.
githubHeadSha
}
/next
\`\`\`
</details>
...
...
.github/actions/next-stats-action/src/prepare/action-info.js
View file @
264d7962
...
...
@@ -16,6 +16,7 @@ module.exports = function actionInfo() {
GITHUB_REPOSITORY
,
GITHUB_EVENT_PATH
,
PR_STATS_COMMENT_TOKEN
,
PREVIEW_BUILDS_BASE_URL
,
}
=
process
.
env
delete
process
.
env
.
GITHUB_TOKEN
...
...
@@ -63,6 +64,8 @@ module.exports = function actionInfo() {
isRelease
:
GITHUB_REPOSITORY
===
'vercel/next.js'
&&
(
GITHUB_REF
||
''
).
includes
(
'canary'
),
previewBuildsBaseUrl
:
PREVIEW_BUILDS_BASE_URL
||
'https://vercel-packages.vercel.app/next'
,
}
if
(
info
.
isRelease
)
{
...
...
.github/workflows/build_and_deploy.yml
View file @
264d7962
...
...
@@ -581,7 +581,7 @@ jobs:
-
name
:
Create tarballs
# github.event.after is available on push and pull_request#synchronize events.
# For workflow_dispatch events, github.sha is the head commit.
run
:
node scripts/create-preview-tarballs.js "${{ github.event.after || github.sha }}" "${{ runner.temp }}/preview-tarballs"
run
:
node scripts/create-preview-tarballs.js "${{ github.event.after || github.sha }}" "${{ runner.temp }}/preview-tarballs"
"${{ vars.PREVIEW_BUILDS_BASE_URL }}"
-
name
:
Upload tarballs
uses
:
actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
# v7.0.1
...
...
.github/workflows/build_and_test.yml
View file @
264d7962
...
...
@@ -743,7 +743,8 @@ jobs:
node scripts/test-new-tests.mjs \
--flake-detection \
--mode dev \
--group ${{ matrix.group }}
--group ${{ matrix.group }} \
--preview-builds-base-url "${{ vars.PREVIEW_BUILDS_BASE_URL }}"
stepName
:
'
test-new-tests-dev-${{matrix.group}}'
timeout_minutes
:
60
# Increase the default timeout as tests are intentionally run multiple times to detect flakes
...
...
@@ -768,7 +769,8 @@ jobs:
node scripts/test-new-tests.mjs \
--flake-detection \
--mode start \
--group ${{ matrix.group }}
--group ${{ matrix.group }} \
--preview-builds-base-url "${{ vars.PREVIEW_BUILDS_BASE_URL }}"
stepName
:
'
test-new-tests-start-${{matrix.group}}'
timeout_minutes
:
60
# Increase the default timeout as tests are intentionally run multiple times to detect flakes
secrets
:
inherit
...
...
@@ -794,7 +796,8 @@ jobs:
export __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true
node scripts/test-new-tests.mjs \
--mode deploy \
--group ${{ matrix.group }}
--group ${{ matrix.group }} \
--preview-builds-base-url "${{ vars.PREVIEW_BUILDS_BASE_URL }}"
stepName
:
'
test-new-tests-deploy-${{matrix.group}}'
secrets
:
inherit
...
...
@@ -823,7 +826,8 @@ jobs:
export NEXT_E2E_TEST_TIMEOUT=240000
node scripts/test-new-tests.mjs \
--mode deploy \
--group ${{ matrix.group }}
--group ${{ matrix.group }} \
--preview-builds-base-url "${{ vars.PREVIEW_BUILDS_BASE_URL }}"
stepName
:
'
test-new-tests-deploy-cache-components-${{matrix.group}}'
secrets
:
inherit
...
...
.github/workflows/build_reusable.yml
View file @
264d7962
...
...
@@ -123,6 +123,9 @@ env:
VERCEL_ADAPTER_TEST_TEAM
:
vtest314-next-adapter-e2e-tests
VERCEL_TURBOPACK_TEST_TOKEN
:
${{ secrets.VERCEL_TURBOPACK_TEST_TOKEN }}
VERCEL_TURBOPACK_TEST_TEAM
:
vtest314-next-turbo-e2e-tests
# Read token for the auth-protected preview-builds npm mirror, used by deploy
# tests to install Next.js artifacts during the remote build.
PREVIEW_BUILDS_READ_TOKEN
:
${{ secrets.PREVIEW_BUILDS_READ_TOKEN }}
NEXT_TEST_PREFER_OFFLINE
:
1
NEXT_CI_RUNNER
:
${{ inputs.runs_on_labels }}
NEXT_TEST_PROXY_ADDRESS
:
${{ inputs.overrideProxyAddress || '' }}
...
...
.github/workflows/pull_request_stats.yml
View file @
264d7962
...
...
@@ -78,6 +78,7 @@ jobs:
TURBO_TEAM
:
${{ env.TURBO_TEAM }}
TURBO_TOKEN
:
${{ secrets.TURBO_TOKEN }}
TURBO_CACHE
:
${{ env.TURBO_CACHE }}
PREVIEW_BUILDS_BASE_URL
:
${{ vars.PREVIEW_BUILDS_BASE_URL }}
-
name
:
Upload stats results
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
...
...
.github/workflows/test_e2e_deploy_release.yml
View file @
264d7962
...
...
@@ -128,6 +128,7 @@ jobs:
NEXT_TEST_DEPLOY_SCRIPT_PATH="${{ github.event.inputs.deployScriptPath || '' }}" \
NEXT_TEST_DEPLOY_LOGS_SCRIPT_PATH="${{ github.event.inputs.deployLogsScriptPath || '' }}" \
NEXT_TEST_CLEANUP_SCRIPT_PATH="${{ github.event.inputs.cleanupScriptPath || '' }}" \
NEXT_TEST_PREVIEW_BUILDS_BASE_URL="${{ vars.PREVIEW_BUILDS_BASE_URL }}" \
node run-tests.js --timings --require-timings -g ${{ matrix.group }} -c 2 --type e2e
testTimingsArtifact
:
'
test-timings'
skipNativeBuild
:
'
yes'
...
...
@@ -173,6 +174,7 @@ jobs:
NEXT_TEST_DEPLOY_SCRIPT_PATH="${{ github.event.inputs.deployScriptPath || '' }}" \
NEXT_TEST_DEPLOY_LOGS_SCRIPT_PATH="${{ github.event.inputs.deployLogsScriptPath || '' }}" \
NEXT_TEST_CLEANUP_SCRIPT_PATH="${{ github.event.inputs.cleanupScriptPath || '' }}" \
NEXT_TEST_PREVIEW_BUILDS_BASE_URL="${{ vars.PREVIEW_BUILDS_BASE_URL }}" \
node run-tests.js --timings --require-timings -g ${{ matrix.group }} -c 2 --type e2e
testTimingsArtifact
:
'
test-timings'
skipNativeBuild
:
'
yes'
...
...
@@ -216,6 +218,7 @@ jobs:
NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json" \
NEXT_TEST_VERSION="${{ github.event.inputs.nextVersion || needs.setup.outputs.next-version || 'canary' }}" \
VERCEL_CLI_VERSION="${{ github.event.inputs.vercelCliVersion || 'vercel@latest' }}" \
NEXT_TEST_PREVIEW_BUILDS_BASE_URL="${{ vars.PREVIEW_BUILDS_BASE_URL }}" \
node run-tests.js --timings --require-timings -g ${{ matrix.group }} -c 2 --type e2e
testTimingsArtifact
:
'
test-timings'
skipNativeBuild
:
'
yes'
...
...
scripts/create-preview-tarballs.js
View file @
264d7962
...
...
@@ -8,7 +8,9 @@ async function main() {
const
[
githubHeadSha
,
tarballDirectory
=
path
.
join
(
os
.
tmpdir
(),
'vercel-nextjs-preview-tarballs'
),
baseUrlArg
,
]
=
process
.
argv
.
slice
(
2
)
const
baseUrl
=
baseUrlArg
||
'https://vercel-packages.vercel.app/next'
const
repoRoot
=
path
.
resolve
(
__dirname
,
'..'
)
await
fs
.
mkdir
(
tarballDirectory
,
{
recursive
:
true
})
...
...
@@ -87,13 +89,13 @@ async function main() {
for
(
const
packageInfo
of
packages
)
{
packagesByVersion
.
set
(
packageInfo
.
name
,
`
https://vercel-packages.vercel.app/next
/commits/
${
githubHeadSha
}
/
${
packageInfo
.
name
}
`
`
${
baseUrl
}
/commits/
${
githubHeadSha
}
/
${
packageInfo
.
name
}
`
)
}
for
(
const
nextSwcPackageName
of
nextSwcPackageNames
)
{
packagesByVersion
.
set
(
nextSwcPackageName
,
`
https://vercel-packages.vercel.app/next
/commits/
${
githubHeadSha
}
/
${
nextSwcPackageName
}
`
`
${
baseUrl
}
/commits/
${
githubHeadSha
}
/
${
nextSwcPackageName
}
`
)
}
...
...
scripts/test-new-tests.mjs
View file @
264d7962
...
...
@@ -14,11 +14,14 @@ async function main() {
const
argv
=
await
yargs
(
process
.
argv
.
slice
(
2
))
.
string
(
'mode'
)
.
string
(
'group'
)
.
string
(
'preview-builds-base-url'
)
.
boolean
(
'flake-detection'
).
argv
const
testMode
=
argv
.
mode
const
isFlakeDetectionMode
=
argv
[
'flake-detection'
]
const
attempts
=
isFlakeDetectionMode
?
3
:
1
const
previewBuildsBaseUrl
=
argv
[
'preview-builds-base-url'
]
||
'https://vercel-packages.vercel.app/next'
if
(
testMode
&&
!
[
'dev'
,
'deploy'
,
'start'
].
includes
(
testMode
))
{
throw
new
Error
(
...
...
@@ -92,16 +95,21 @@ async function main() {
// PR number endpoint (which resolves the PR to a SHA on every request).
const
nextTestVersion
=
testMode
===
'deploy'
?
`
https://vercel-packages.vercel.app/next
/commits/
${
commitSha
}
/next`
?
`
${
previewBuildsBaseUrl
}
/commits/
${
commitSha
}
/next`
:
undefined
const
previewBuildsReadToken
=
process
.
env
.
PREVIEW_BUILDS_READ_TOKEN
if
(
nextTestVersion
)
{
console
.
log
(
`Verifying artifacts for commit
${
commitSha
}
`
)
// Attempt to fetch the deploy artifacts for the commit
// These might take a moment to become available, so we'll retry a few times
const
fetchHeaders
=
previewBuildsReadToken
?
{
Authorization
:
`Bearer
${
previewBuildsReadToken
}
`
}
:
undefined
const
fetchWithRetry
=
async
(
url
,
retries
=
5
,
timeout
=
5000
)
=>
{
for
(
let
i
=
0
;
i
<
retries
;
i
++
)
{
const
res
=
await
fetch
(
url
)
const
res
=
await
fetch
(
url
,
{
headers
:
fetchHeaders
}
)
if
(
res
.
ok
)
{
return
res
}
else
if
(
i
<
retries
-
1
)
{
...
...
@@ -159,6 +167,7 @@ async function main() {
...
process
.
env
,
NEXT_TEST_MODE
:
testMode
,
NEXT_TEST_VERSION
:
nextTestVersion
,
NEXT_TEST_PREVIEW_BUILDS_BASE_URL
:
previewBuildsBaseUrl
,
NEXT_EXTERNAL_TESTS_FILTERS
,
NEXT_FLAKE_DETECTION
:
'1'
,
IS_TURBOPACK_TEST
:
'1'
,
...
...
@@ -179,6 +188,7 @@ async function main() {
NEXT_EXTERNAL_TESTS_FILTERS
,
NEXT_TEST_MODE
:
testMode
,
NEXT_TEST_VERSION
:
nextTestVersion
,
NEXT_TEST_PREVIEW_BUILDS_BASE_URL
:
previewBuildsBaseUrl
,
IS_WEBPACK_TEST
:
'1'
,
},
})
...
...
test/lib/next-modes/next-deploy.ts
View file @
264d7962
...
...
@@ -189,6 +189,8 @@ export class NextDeployInstance extends NextInstance {
super
.
setup
(
parentSpan
)
await
super
.
createTestDir
({
parentSpan
,
skipInstall
:
true
})
await
this
.
writeMirrorNpmrcIfNecessary
()
const
existingDeployUrl
=
process
.
env
.
NEXT_TEST_DEPLOY_URL
?.
trim
()
const
customDeployScriptPath
=
process
.
env
.
NEXT_TEST_DEPLOY_SCRIPT_PATH
?.
trim
()
...
...
@@ -443,6 +445,36 @@ export class NextDeployInstance extends NextInstance {
// output other unrelated logs to stderr.
}
// When the preview-builds npm mirror is auth-protected, the deploy build
// installs Next.js artifacts from it and needs credentials. We write an
// `.npmrc` with a read token (provided as a CI secret) so the remote install
// can authenticate. Only written when the token is set, so unprotected and
// local deploy runs are unaffected.
private
async
writeMirrorNpmrcIfNecessary
():
Promise
<
void
>
{
const
token
=
process
.
env
.
PREVIEW_BUILDS_READ_TOKEN
const
baseUrlRaw
=
process
.
env
.
NEXT_TEST_PREVIEW_BUILDS_BASE_URL
if
(
!
token
||
!
baseUrlRaw
)
{
require
(
'console'
).
log
(
`Skipping .npmrc write for preview-builds mirror: missing token or base URL`
)
return
}
const
baseUrl
=
new
URL
(
baseUrlRaw
)
// Derive the npmrc auth key from the mirror base URL: strip the scheme and
// ensure a trailing slash so it matches requests to that registry path.
const
registryKey
=
`//
${
baseUrl
.
host
}${
baseUrl
.
pathname
.
replace
(
/
\/?
$/
,
'/'
)}
`
require
(
'console'
).
log
(
`Writing .npmrc for preview-builds mirror:
${
registryKey
}
`
)
await
fs
.
writeFile
(
path
.
join
(
this
.
testDir
,
'.npmrc'
),
`
${
registryKey
}
:_authToken=
${
token
}
\n`
)
}
private
async
configureProxyAddress
():
Promise
<
void
>
{
// If configured, we should configure the `/etc/hosts` file to point the
// deployment domain to the specified proxy address.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment