/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v16.2.12
scripts/release-github-auth.js
74 строки
2 KB
Zack Tanner
[ci]: app-based release workflow (#93245)
28 апр 2026, 00:48
28 апр 2026, 00:48
a3bb370
Код
Авторство
О чём код?
// @ts-check const execa = require('execa') const REPO_URL = 'github.com/vercel/next.js.git' function getGitHubToken() { return ( process.env.RELEASE_GITHUB_TOKEN || process.env.RELEASE_BOT_GITHUB_TOKEN ) } function getGitHubTokenMissingMessage() { return 'Missing RELEASE_GITHUB_TOKEN or RELEASE_BOT_GITHUB_TOKEN' } function getGitUser() { const appSlug = process.env.RELEASE_GITHUB_APP_SLUG const appUserId = process.env.RELEASE_GITHUB_APP_USER_ID if (appSlug && appUserId) { return { name: `${appSlug}[bot]`, email: `${appUserId}+${appSlug}[bot]@users.noreply.github.com`, } } return { name: process.env.RELEASE_GITHUB_USER_NAME || 'nextjs-bot', email: process.env.RELEASE_GITHUB_USER_EMAIL || 'it+nextjs-bot@vercel.com', } } async function configureGitHubAuth(token) { const gitUser = getGitUser() const remoteUrl = `https://x-access-token:${encodeURIComponent( token )}@${REPO_URL}` await execa('git', ['remote', 'set-url', 'origin', remoteUrl], { stdio: 'inherit', }) await execa('git', ['config', 'user.name', gitUser.name], { stdio: 'inherit', }) await execa('git', ['config', 'user.email', gitUser.email], { stdio: 'inherit', }) } async function verifyGitHubApiAccess(token, path, label) { const response = await fetch(`https://api.github.com${path}`, { headers: { Accept: 'application/vnd.github+json', Authorization: `Bearer ${token}`, 'X-GitHub-Api-Version': '2022-11-28', }, }) if (!response.ok) { throw new Error( `Failed to verify GitHub API access for ${label} (${response.status}): ${await response.text()}` ) } console.log(`Verified GitHub API access for ${label}`) } module.exports = { configureGitHubAuth, getGitHubToken, getGitHubTokenMissingMessage, verifyGitHubApiAccess, }