1
0
mirror of synced 2026-01-06 06:02:35 -05:00

Merge pull request #10347 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2021-09-27 18:44:24 -04:00
committed by GitHub
4 changed files with 82 additions and 8 deletions

15
package-lock.json generated
View File

@@ -172,7 +172,8 @@
"supertest": "^6.1.6",
"typescript": "^4.4.3",
"url-template": "^2.0.8",
"website-scraper": "^4.2.3"
"website-scraper": "^4.2.3",
"yesno": "^0.3.1"
},
"engines": {
"node": ">= 16.0.0"
@@ -25346,6 +25347,12 @@
"fd-slicer": "~1.1.0"
}
},
"node_modules/yesno": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/yesno/-/yesno-0.3.1.tgz",
"integrity": "sha512-7RbCXegyu6DykWPWU0YEtW8gFJH8KBL2d5l2fqB0XpkH0Y9rk59YSSWpzEv7yNJBGAouPc67h3kkq0CZkpBdFw==",
"dev": true
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
@@ -45079,6 +45086,12 @@
"fd-slicer": "~1.1.0"
}
},
"yesno": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/yesno/-/yesno-0.3.1.tgz",
"integrity": "sha512-7RbCXegyu6DykWPWU0YEtW8gFJH8KBL2d5l2fqB0XpkH0Y9rk59YSSWpzEv7yNJBGAouPc67h3kkq0CZkpBdFw==",
"dev": true
},
"yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

View File

@@ -174,7 +174,8 @@
"supertest": "^6.1.6",
"typescript": "^4.4.3",
"url-template": "^2.0.8",
"website-scraper": "^4.2.3"
"website-scraper": "^4.2.3",
"yesno": "^0.3.1"
},
"engines": {
"node": ">= 16.0.0"

View File

@@ -11,6 +11,14 @@
// - Optionally, supply a GitHub PAT as the DOCUBOT_REPO_PAT environment
// variable if you want to support content from the `docs-early-access` repo
//
// For production deployment in particular, you should ideally:
// - Supply the aforementioned DOCUBOT_REPO_PAT environment variable to support
// content from the `docs-early-access` repo. In most cases, you should be
// able to just set this to the same value as GITHUB_TOKEN when running this
// script locally as it just needs read access to that repo.
// - Supply our Fastly API token as the FASTLY_TOKEN enviroment variable
// - Supply our Fastly Service ID as the FASTLY_SERVICE_ID environment variable
//
// Examples:
// - Deploy a PR to Staging and force the Heroku App to be rebuilt from scratch (by default):
// script/deploy.js --staging https://github.com/github/docs/pull/9876
@@ -29,10 +37,13 @@
import dotenv from 'dotenv'
import program from 'commander'
import { has } from 'lodash-es'
import yesno from 'yesno'
import getOctokit from './helpers/github.js'
import parsePrUrl from './deployment/parse-pr-url.js'
import deployToStaging from './deployment/deploy-to-staging.js'
import undeployFromStaging from './deployment/undeploy-from-staging.js'
import deployToProduction from './deployment/deploy-to-production.js'
import purgeEdgeCache from './deployment/purge-edge-cache.js'
dotenv.config()
@@ -71,7 +82,7 @@ const opts = program.opts()
const isProduction = opts.production === true
const isStaging = has(opts, 'staging')
const prUrl = opts.staging
const forceRebuild = opts.rebuild !== false
const forceRebuild = !isProduction && opts.rebuild !== false
const destroy = opts.destroy === true
//
@@ -138,12 +149,57 @@ async function deploy() {
}
async function deployProduction() {
// TODO: Request confirmation before deploying to production
const { DOCUBOT_REPO_PAT, FASTLY_TOKEN, FASTLY_SERVICE_ID } = process.env
invalidateAndExit(
'commander.invalidArgument',
`error: option '${PRODUCTION_FLAG}' is not yet implemented. SOON!`
)
// Warn if @docubot PAT is not found
if (!DOCUBOT_REPO_PAT) {
console.warn(
'⚠️ You did not supply a DOCUBOT_REPO_PAT environment variable.\nWithout it, this deployment will not contain any Early Access content!'
)
}
// Warn if Fastly credentials are not found
if (!FASTLY_TOKEN) {
console.warn(
'⚠️ You did not supply a FASTLY_TOKEN environment variable.\nWithout it, this deployment will not soft-purge the Fastly cache!'
)
}
if (!FASTLY_SERVICE_ID) {
console.warn(
'⚠️ You did not supply a FASTLY_SERVICE_ID environment variable.\nWithout it, this deployment will not soft-purge the Fastly cache!'
)
}
if (!process.env.FASTLY_SURROGATE_KEY) {
// Default to our current Fastly surrogate key if unspecified
process.env.FASTLY_SURROGATE_KEY = 'all-the-things'
}
// Request confirmation before deploying to production
const proceed = await yesno({
question: '\n🛑 You have selected to deploy to production. ARE YOU CERTAIN!?',
defaultValue: null,
})
if (!proceed) {
console.error('\n❌ User canceled the production deployment! Halting...')
process.exit(1)
}
// This helper uses the `GITHUB_TOKEN` implicitly
const octokit = getOctokit()
try {
await deployToProduction({
octokit,
includeDelayForPreboot: !!(FASTLY_TOKEN && FASTLY_SERVICE_ID),
})
await purgeEdgeCache()
} catch (error) {
console.error(`Failed to deploy production: ${error.message}`)
console.error(error)
process.exit(1)
}
}
async function deployStaging({ owner, repo, pullNumber, forceRebuild = false, destroy = false }) {

View File

@@ -355,6 +355,10 @@ export default async function deployToProduction({
// Is there a faster alternative than this arbitrary delay? For example,
// is there some Heroku API we can query to see when this release is
// considered to be the live one, or when the old dynos are shut down?
} else {
console.warn(
'⚠️ Bypassing the wait for Heroku Preboot....\nPlease understand that your changes will not be visible for at least another 2 minutes!'
)
}
// Report success!