Branch was updated using the 'autoupdate branch' Actions workflow.
This commit is contained in:
7
.github/workflows/staging-deploy-pr.yml
vendored
7
.github/workflows/staging-deploy-pr.yml
vendored
@@ -180,7 +180,12 @@ jobs:
|
||||
# Append early access content into the temp directory
|
||||
- if: ${{ github.repository == 'github/docs-internal' }}
|
||||
name: Merge in the early access content
|
||||
run: rsync -ai assets content data "$RUNNER_TEMP/"
|
||||
run: |
|
||||
rsync -aiR \
|
||||
assets/images/early-access \
|
||||
content/early-access \
|
||||
data/early-access \
|
||||
"$RUNNER_TEMP/"
|
||||
|
||||
- if: ${{ github.repository == 'github/docs-internal' }}
|
||||
name: Create an updated archive
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { getPathWithoutLanguage, getPathWithoutVersion } from '../lib/path-utils.js'
|
||||
import getLinkData from '../lib/get-link-data.js'
|
||||
import renderContent from '../lib/render-content/renderContent.js'
|
||||
|
||||
export default async function learningTrack(req, res, next) {
|
||||
const noTrack = () => {
|
||||
@@ -23,15 +24,21 @@ export default async function learningTrack(req, res, next) {
|
||||
const guidePath = getPathWithoutLanguage(getPathWithoutVersion(req.pagePath))
|
||||
let guideIndex = track.guides.findIndex((path) => path === guidePath)
|
||||
|
||||
// The learning track path may use Liquid version conditionals, handle the
|
||||
// case where the requested path is a learning track path but won't match
|
||||
// because of a Liquid conditional.
|
||||
if (guideIndex < 0) {
|
||||
guideIndex = await indexOfLearningTrackGuide(track.guides, guidePath, req.context)
|
||||
}
|
||||
|
||||
// Also check if the learning track path is now a redirect to the requested
|
||||
// page, we still want to render the learning track banner in that case.
|
||||
// Also handles Liquid conditionals in the track path.
|
||||
if (guideIndex < 0) {
|
||||
// Also check if the learning track URL is now a redirect to the requested
|
||||
// page, we still want to render the learning track banner in that case.
|
||||
for (const redirect of req.context.page.redirect_from) {
|
||||
track.guides.forEach((path, i) => {
|
||||
if (path === redirect) {
|
||||
guideIndex = i
|
||||
}
|
||||
})
|
||||
if (guideIndex >= 0) break
|
||||
|
||||
guideIndex = await indexOfLearningTrackGuide(track.guides, redirect, req.context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,3 +69,24 @@ export default async function learningTrack(req, res, next) {
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
// Find the index of a learning track guide path in an array of guide paths,
|
||||
// return -1 if not found.
|
||||
async function indexOfLearningTrackGuide(trackGuidePaths, guidePath, context) {
|
||||
let guideIndex = -1
|
||||
const renderOpts = { textOnly: true, encodeEntities: true }
|
||||
|
||||
for (let i = 0; i < trackGuidePaths.length; i++) {
|
||||
// Learning track URLs may have Liquid conditionals.
|
||||
const renderedGuidePath = await renderContent(trackGuidePaths[i], context, renderOpts)
|
||||
|
||||
if (!renderedGuidePath) continue
|
||||
|
||||
if (renderedGuidePath === guidePath) {
|
||||
guideIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return guideIndex
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ export default async function deployToProduction({
|
||||
// If prebuilt: prevent the Heroku Node.js buildpack from using `npm ci` as it would
|
||||
// delete all of the vendored "node_modules/" directory.
|
||||
USE_NPM_INSTALL: isPrebuilt.toString(),
|
||||
...(!isPrebuilt && DOCUBOT_REPO_PAT && { DOCUBOT_REPO_PAT }),
|
||||
// If not prebuilt, include the PAT required for cloning the `docs-early-access` repo.
|
||||
// Otherwise, set it to `null` to unset it from the environment for security.
|
||||
DOCUBOT_REPO_PAT: (!isPrebuilt && DOCUBOT_REPO_PAT) || null,
|
||||
}
|
||||
|
||||
const workflowRunLog = runId ? `https://github.com/${owner}/${repo}/actions/runs/${runId}` : null
|
||||
|
||||
@@ -54,9 +54,11 @@ export default async function deployToStaging({
|
||||
// If prebuilt: prevent the Heroku Node.js buildpack from using `npm ci` as it would
|
||||
// delete all of the vendored "node_modules/" directory.
|
||||
USE_NPM_INSTALL: isPrebuilt.toString(),
|
||||
// IMPORTANT: This secret should only be set in the private repo!
|
||||
// If not prebuilt, include the PAT required for cloning the `docs-early-access` repo.
|
||||
// Otherwise, set it to `null` to unset it from the environment for security.
|
||||
DOCUBOT_REPO_PAT: (isPrivateRepo && !isPrebuilt && DOCUBOT_REPO_PAT) || null,
|
||||
// IMPORTANT: These secrets should only be set in the private repo!
|
||||
// This is only required for cloning the `docs-early-access` repo
|
||||
...(isPrivateRepo && !isPrebuilt && DOCUBOT_REPO_PAT && { DOCUBOT_REPO_PAT }),
|
||||
// These are required for Hydro event tracking
|
||||
...(isPrivateRepo && HYDRO_ENDPOINT && HYDRO_SECRET && { HYDRO_ENDPOINT, HYDRO_SECRET }),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user