@@ -486,12 +486,8 @@ jobs:
486486 - name : Install dependencies
487487 run : npm ci
488488
489- - name : Install one-off development-only dependencies
490- run : npm install --no-save --include=optional esm
491-
492489 - name : Deploy
493490 id : deploy
494- uses : actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
495491 env :
496492 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
497493 HEROKU_API_TOKEN : ${{ secrets.HEROKU_API_TOKEN }}
@@ -503,69 +499,7 @@ jobs:
503499 ACTIONS_RUN_LOG : ${{ env.ACTIONS_RUN_LOG }}
504500 HEAD_SHA : ${{ needs.pr-metadata.outputs.head_sha }}
505501 ALLOWED_POLLING_FAILURES_PER_PHASE : ' 15'
506- with :
507- script : |
508- const { GITHUB_TOKEN, HEROKU_API_TOKEN } = process.env
509-
510- // Exit if GitHub Actions PAT is not found
511- if (!GITHUB_TOKEN) {
512- throw new Error('You must supply a GITHUB_TOKEN environment variable!')
513- }
514-
515- // Exit if Heroku API token is not found
516- if (!HEROKU_API_TOKEN) {
517- throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
518- }
519-
520- // Workaround to allow us to load ESM files with `require(...)`
521- const esm = require('esm')
522- require = esm({})
523-
524- const { default: parsePrUrl } = require('./script/deployment/parse-pr-url')
525- const { default: getOctokit } = require('./script/helpers/github')
526- const { default: deployToStaging } = require('./script/deployment/deploy-to-staging')
527-
528- // This helper uses the `GITHUB_TOKEN` implicitly!
529- // We're using our usual version of Octokit vs. the provided `github`
530- // instance to avoid versioning discrepancies.
531- const octokit = getOctokit()
532-
533- try {
534- const { PR_URL, SOURCE_BLOB_URL, CONTEXT_NAME, ACTIONS_RUN_LOG, HEAD_SHA } = process.env
535- const { owner, repo, pullNumber } = parsePrUrl(PR_URL)
536- if (!owner || !repo || !pullNumber) {
537- throw new Error(`'pullRequestUrl' input must match URL format 'https://github.com/github/(docs|docs-internal)/pull/123' but was '${PR_URL}'`)
538- }
539-
540- const { data: pullRequest } = await octokit.pulls.get({
541- owner,
542- repo,
543- pull_number: pullNumber
544- })
545-
546- await deployToStaging({
547- octokit,
548- pullRequest,
549- forceRebuild: false,
550- // These parameters will ONLY be set by Actions
551- sourceBlobUrl: SOURCE_BLOB_URL,
552- runId: context.runId
553- })
554-
555- await github.repos.createCommitStatus({
556- owner,
557- repo,
558- sha: HEAD_SHA,
559- context: CONTEXT_NAME,
560- state: 'success',
561- description: 'Successfully deployed! See logs.',
562- target_url: ACTIONS_RUN_LOG
563- })
564- } catch (error) {
565- console.error(`Failed to deploy to staging: ${error.message}`)
566- console.error(error)
567- throw error
568- }
502+ run : .github/actions-scripts/staging-deploy.js
569503
570504 - name : Mark the deployment as inactive if timed out
571505 uses : actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
0 commit comments