.strategy.matrix`](/actions/reference/w
### Caching dependencies
-{% data variables.product.prodname_dotcom %}-hosted runners are started as fresh environments for each job, so if your jobs regularly reuse dependencies, you can consider caching these files to help improve performance. Once the cache is created, it is available to all workflows in the same repository.
+{% data variables.product.prodname_dotcom %}-hosted runners are started as fresh environments for each job, so if your jobs regularly reuse dependencies, you can consider caching these files to help improve performance. Once the cache is created, it is available to all workflows in the same repository.
This example demonstrates how to cache the ` ~/.npm` directory:
@@ -106,7 +106,7 @@ jobs:
```
{% endraw %}
-For more information, see "[Caching dependencies to speed up workflows](/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)."
+For more information, see "Caching dependencies to speed up workflows."
### Using databases and service containers
@@ -136,7 +136,7 @@ For more information, see "[Using databases and service containers](/actions/con
### Using labels to route workflows
-This feature helps you assign jobs to a specific self-hosted runner. If you want to be sure that a particular type of runner will process your job, you can use labels to control where jobs are executed. You can assign labels to a self-hosted runner, and then refer to these labels in your YAML workflow, ensuring that the job is routed in a predictable way.
+This feature helps you assign jobs to a specific self-hosted runner. If you want to be sure that a particular type of runner will process your job, you can use labels to control where jobs are executed. You can assign labels to a self-hosted runner, and then refer to these labels in your YAML workflow, ensuring that the job is routed in a predictable way.
This example shows how a workflow can use labels to specify the required runner:
diff --git a/content/actions/learn-github-actions/migrating-from-circleci-to-github-actions.md b/content/actions/learn-github-actions/migrating-from-circleci-to-github-actions.md
index 17d1431c82..497f6175fc 100644
--- a/content/actions/learn-github-actions/migrating-from-circleci-to-github-actions.md
+++ b/content/actions/learn-github-actions/migrating-from-circleci-to-github-actions.md
@@ -101,7 +101,7 @@ GitHub Actions
-For more information, see "[Caching dependencies to speed up workflows](/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)."
+{% data variables.product.prodname_actions %} caching is only applicable to {% data variables.product.prodname_dotcom %}-hosted runners. For more information, see "Caching dependencies to speed up workflows."
{% data variables.product.prodname_actions %} does not have an equivalent of CircleCI’s Docker Layer Caching (or DLC).
diff --git a/content/actions/learn-github-actions/migrating-from-gitlab-cicd-to-github-actions.md b/content/actions/learn-github-actions/migrating-from-gitlab-cicd-to-github-actions.md
index 618503642e..80d2f12511 100644
--- a/content/actions/learn-github-actions/migrating-from-gitlab-cicd-to-github-actions.md
+++ b/content/actions/learn-github-actions/migrating-from-gitlab-cicd-to-github-actions.md
@@ -262,7 +262,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: echo "This job will be run first, in parallel with build_a"
-
+
test_ab:
runs-on: ubuntu-latest
needs: [build_a,build_b]
@@ -346,7 +346,7 @@ jobs:
-For more information, see "[Caching dependencies to speed up workflows](/actions/guides/caching-dependencies-to-speed-up-workflows)."
+{% data variables.product.prodname_actions %} caching is only applicable to {% data variables.product.prodname_dotcom %}-hosted runners. For more information, see "Caching dependencies to speed up workflows."
### Artifacts
@@ -367,7 +367,7 @@ GitLab CI/CD
{% raw %}
```yaml
-script:
+script:
artifacts:
paths:
- math-homework.txt
@@ -414,7 +414,7 @@ GitLab CI/CD
container-job:
variables:
POSTGRES_PASSWORD: postgres
- # The hostname used to communicate with the
+ # The hostname used to communicate with the
# PostgreSQL service container
POSTGRES_HOST: postgres
# The default PostgreSQL port
@@ -423,10 +423,10 @@ container-job:
services:
- postgres
script:
- # Performs a clean installation of all dependencies
+ # Performs a clean installation of all dependencies
# in the `package.json` file
- npm ci
- # Runs a script that creates a PostgreSQL client,
+ # Runs a script that creates a PostgreSQL client,
# populates the client with data, and retrieves data
- node client.js
tags:
@@ -452,7 +452,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v2
- # Performs a clean installation of all dependencies
+ # Performs a clean installation of all dependencies
# in the `package.json` file
- name: Install dependencies
run: npm ci
@@ -462,7 +462,7 @@ jobs:
# populates the client with data, and retrieves data
run: node client.js
env:
- # The hostname used to communicate with the
+ # The hostname used to communicate with the
# PostgreSQL service container
POSTGRES_HOST: postgres
# The default PostgreSQL port
diff --git a/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md b/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md
index 36ad353b04..ff321c9472 100644
--- a/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md
+++ b/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md
@@ -184,7 +184,7 @@ When migrating from Travis CI, consider the following key features in {% data va
#### Hosting your own runners
-If your jobs require specific hardware or software, {% data variables.product.prodname_actions %} allows you to host your own runners and send your jobs to them for processing. {% data variables.product.prodname_actions %} also lets you use policies to control how these runners are accessed, granting access at the organization or repository level. For more information, see ["Hosting your own runners](/actions/hosting-your-own-runners)."
+If your jobs require specific hardware or software, {% data variables.product.prodname_actions %} allows you to host your own runners and send your jobs to them for processing. {% data variables.product.prodname_actions %} also lets you use policies to control how these runners are accessed, granting access at the organization or repository level. For more information, see ["Hosting your own runners](/actions/hosting-your-own-runners)."
#### Concurrent jobs and execution time
@@ -213,7 +213,7 @@ For example:
shell: bash
```
-### Error handling in {% data variables.product.prodname_actions %}
+### Error handling in {% data variables.product.prodname_actions %}
When migrating to {% data variables.product.prodname_actions %}, there are different approaches to error handling that you might need to be aware of.
@@ -288,7 +288,7 @@ jobs:
### Caching dependencies
-Travis CI and {% data variables.product.prodname_actions %} let you manually cache dependencies for later reuse. This example demonstrates the cache syntax for each system.
+Travis CI and {% data variables.product.prodname_actions %} let you manually cache dependencies for later reuse. This example demonstrates the cache syntax for each system.
@@ -323,7 +323,7 @@ cache: npm
-For more information, see "[Caching dependencies to speed up workflows](/actions/guides/caching-dependencies-to-speed-up-workflows)."
+{% data variables.product.prodname_actions %} caching is only applicable to {% data variables.product.prodname_dotcom %}-hosted runners. For more information, see "Caching dependencies to speed up workflows."
### Examples of common tasks
diff --git a/content/actions/reference/usage-limits-billing-and-administration.md b/content/actions/reference/usage-limits-billing-and-administration.md
index 1cc3b5a2e6..9029966809 100644
--- a/content/actions/reference/usage-limits-billing-and-administration.md
+++ b/content/actions/reference/usage-limits-billing-and-administration.md
@@ -76,6 +76,7 @@ For more information, see:
- "[Disabling or limiting {% data variables.product.prodname_actions %} for your organization](/github/setting-up-and-managing-organizations-and-teams/disabling-or-limiting-github-actions-for-your-organization)"{% if currentVersion == "free-pro-team@latest" %}
- "[Enforcing {% data variables.product.prodname_actions %} policies in your enterprise account](/github/setting-up-and-managing-your-enterprise/enforcing-github-actions-policies-in-your-enterprise-account)" for {% data variables.product.prodname_ghe_cloud %}{% endif %}
+{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
### Disabling and enabling workflows
You can enable and disable individual workflows in your repository on {% data variables.product.prodname_dotcom %}.
@@ -83,3 +84,4 @@ You can enable and disable individual workflows in your repository on {% data va
{% data reusables.actions.scheduled-workflows-disabled %}
For more information, see "[Disabling and enabling a workflow](/actions/managing-workflow-runs/disabling-and-enabling-a-workflow)."
+{% endif %}
diff --git a/content/developers/apps/identifying-and-authorizing-users-for-github-apps.md b/content/developers/apps/identifying-and-authorizing-users-for-github-apps.md
index d1d6244e66..40d1e72f53 100644
--- a/content/developers/apps/identifying-and-authorizing-users-for-github-apps.md
+++ b/content/developers/apps/identifying-and-authorizing-users-for-github-apps.md
@@ -67,7 +67,7 @@ If the user accepts your request, GitHub redirects back to your site with a temp
{% endnote %}
-Exchange this `code` for an access token. {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %} When expiring tokens are enabled, the access token expires in 8 hours and the refresh token expires in 6 months. Every time you refresh the token, you get a new refresh token. For more information, see "[Refreshing user-to-server access tokens](/apps/building-github-apps/refreshing-user-to-server-access-tokens/)."
+Exchange this `code` for an access token. {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %} When expiring tokens are enabled, the access token expires in 8 hours and the refresh token expires in 6 months. Every time you refresh the token, you get a new refresh token. For more information, see "[Refreshing user-to-server access tokens](/developers/apps/refreshing-user-to-server-access-tokens)."
Expiring user tokens are currently part of the user-to-server token expiration beta and subject to change. To opt-in to the user-to-server token expiration beta feature, see "[Activating beta features for apps](/developers/apps/activating-beta-features-for-apps)."{% endif %}
@@ -462,7 +462,7 @@ While most of your API interaction should occur using your server-to-server inst
* [List teams](/v3/teams/#list-teams)
* [Create a team](/v3/teams/#create-a-team)
-* [Get a team by name](/v3/teams/#get-a-team-by-name)
+* [Get a team by name](/v3/teams/#get-a-team-by-name)
{% if enterpriseServerVersions contains currentVersion and currentVersion ver_lt "enterprise-server@2.21" %}
* [Get a team](/v3/teams/#get-a-team)
{% endif %}
@@ -484,7 +484,7 @@ While most of your API interaction should occur using your server-to-server inst
* [Get an organization](/v3/orgs/#get-an-organization)
* [Update an organization](/v3/orgs/#update-an-organization)
* [List organization memberships for the authenticated user](/v3/orgs/members/#list-organization-memberships-for-the-authenticated-user)
-* [Get an organization membership for the authenticated user](/v3/orgs/members/#get-an-organization-membership-for-the-authenticated-user)
+* [Get an organization membership for the authenticated user](/v3/orgs/members/#get-an-organization-membership-for-the-authenticated-user)
* [Update an organization membership for the authenticated user](/v3/orgs/members/#update-an-organization-membership-for-the-authenticated-user)
* [List organizations for the authenticated user](/v3/orgs/#list-organizations-for-the-authenticated-user)
* [List organizations for a user](/v3/orgs/#list-organizations-for-a-user)
@@ -824,7 +824,7 @@ While most of your API interaction should occur using your server-to-server inst
* [List commit statuses for a reference](/v3/repos/statuses/#list-commit-statuses-for-a-reference)
* [Create a commit status](/v3/repos/statuses/#create-a-commit-status)
-##### Team Discussions
+##### Team Discussions
* [List discussions](/v3/teams/discussions/#list-discussions)
* [Create a discussion](/v3/teams/discussions/#create-a-discussion)
diff --git a/content/github/administering-a-repository/managing-releases-in-a-repository.md b/content/github/administering-a-repository/managing-releases-in-a-repository.md
index 32977281b8..0f4032a957 100644
--- a/content/github/administering-a-repository/managing-releases-in-a-repository.md
+++ b/content/github/administering-a-repository/managing-releases-in-a-repository.md
@@ -15,11 +15,14 @@ versions:
github-ae: '*'
---
+{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" or currentVersion ver_gt "github-ae@latest" %}
+
### About release management
+{% if currentVersion == "free-pro-team@latest" %}
You can also publish an action from a specific release in {% data variables.product.prodname_marketplace %}. For more information, see "Publishing an action in the {% data variables.product.prodname_marketplace %}."
+{% endif %}
-{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" or currentVersion == "github-ae@latest" %}
You can choose whether {% data variables.large_files.product_name_long %} ({% data variables.large_files.product_name_short %}) objects are included in the ZIP files and tarballs that {% data variables.product.product_name %} creates for each release. For more information, see "[Managing {% data variables.large_files.product_name_short %} objects in archives of your repository](/github/administering-a-repository/managing-git-lfs-objects-in-archives-of-your-repository)."
{% endif %}
diff --git a/data/reusables/pre-release-program/expiring-user-access-tokens-beta.md b/data/reusables/pre-release-program/expiring-user-access-tokens-beta.md
index 6bf0fb2ed4..7bed2bb577 100644
--- a/data/reusables/pre-release-program/expiring-user-access-tokens-beta.md
+++ b/data/reusables/pre-release-program/expiring-user-access-tokens-beta.md
@@ -1,4 +1,4 @@
-{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %}
+{% if currentVersion == "free-pro-team@latest" %}
{% note %}
**Note:** Expiring user tokens are currently part of the user-to-server token expiration beta and subject to change. To opt-in to the user-to-server token expiration beta feature, see "[Activating beta features for apps](/developers/apps/activating-beta-features-for-apps)." For more information, see "[Expiring user-to-server access tokens for GitHub Apps](https://developer.github.com/changes/2020-04-30-expiring-user-to-server-access-tokens-for-github-apps)."
diff --git a/lib/check-developer-links.js b/lib/check-developer-links.js
index 81cef84bde..e5e708be88 100644
--- a/lib/check-developer-links.js
+++ b/lib/check-developer-links.js
@@ -1,11 +1,11 @@
const cheerio = require('cheerio')
-const findPage = require('./find-page')
+const findPageInVersion = require('./find-page-in-version')
const renderContent = require('./render-content')
const rewriteLocalLinks = require('./rewrite-local-links')
-const getApplicableVersions = require('./get-applicable-versions')
+const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
const { getPathWithoutLanguage } = require('./path-utils')
-const { getEnterpriseVersionNumber } = require('./patterns')
-const { deprecated } = require('./enterprise-server-releases')
+const { getEnterpriseVersionNumber, adminProduct } = require('./patterns')
+const { deprecated, latest } = require('./enterprise-server-releases')
// internal links will have a language code by the time we're testing them
// we also want to capture same-page anchors (#foo)
@@ -59,7 +59,15 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi
if (gheVersionInLink && deprecated.includes(gheVersionInLink[1])) continue
// look for linked page
- const linkedPage = findPage(link, context.pages, context.redirects, languageCode)
+ const isDotcomOnly = $(internalLink).attr('class')
+
+ // special case for GHES Admin links on dotcom, which are not broken; they go to the latest GHES version
+ let versionToCheck = version
+ if (version === nonEnterpriseDefaultVersion && adminProduct.test(link)) {
+ versionToCheck = `enterprise-server@${latest}`
+ }
+
+ const linkedPage = findPageInVersion(link, context.pages, context.redirects, languageCode, versionToCheck, isDotcomOnly)
if (!linkedPage) {
brokenLinks.links.push({ 'broken link': link, reason: 'linked page not found' })
@@ -79,16 +87,6 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi
.filter(operation => operation.operationId.startsWith(docsPath))
}
- // finding the linked page isn't enough if it's a github.com page; also need to check versions
- if (linkedPage.relativePath.startsWith('github')) {
- const linkedPageVersions = getApplicableVersions(linkedPage.versions, linkedPage.relativePath)
-
- if (!linkedPageVersions.includes(version) && $(internalLink).attr('class') !== 'dotcom-only') {
- brokenLinks.links.push({ 'broken link': link, reason: `${version} not found in linked page versions`, 'linked page': linkedPage.fullPath })
- continue
- }
- }
-
// collect elements of the page that may contain links
const linkedPageContent = linkedPage.relativePath.includes('graphql/reference/objects')
? linkedPage.markdown + context.graphql.prerenderedObjectsForCurrentVersion.html
diff --git a/lib/check-links.js b/lib/check-links.js
index 6729cb77bc..1d000da7f0 100644
--- a/lib/check-links.js
+++ b/lib/check-links.js
@@ -1,11 +1,11 @@
const cheerio = require('cheerio')
-const findPage = require('./find-page')
+const findPageInVersion = require('./find-page-in-version')
const renderContent = require('./render-content')
const rewriteLocalLinks = require('./rewrite-local-links')
-const getApplicableVersions = require('./get-applicable-versions')
+const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
const { getPathWithoutLanguage } = require('./path-utils')
-const { getEnterpriseVersionNumber } = require('./patterns')
-const { deprecated } = require('./enterprise-server-releases')
+const { getEnterpriseVersionNumber, adminProduct } = require('./patterns')
+const { deprecated, latest } = require('./enterprise-server-releases')
// internal links will have a language code by the time we're testing them
// we also want to capture same-page anchors (#foo)
@@ -59,23 +59,21 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi
if (gheVersionInLink && deprecated.includes(gheVersionInLink[1])) continue
// look for linked page
- const linkedPage = findPage(link, context.pages, context.redirects, languageCode)
+ const isDotcomOnly = $(internalLink).attr('class')
+
+ // special case for GHES Admin links on dotcom, which are not broken; they go to the latest GHES version
+ let versionToCheck = version
+ if (version === nonEnterpriseDefaultVersion && adminProduct.test(link)) {
+ versionToCheck = `enterprise-server@${latest}`
+ }
+
+ const linkedPage = findPageInVersion(link, context.pages, context.redirects, languageCode, versionToCheck, isDotcomOnly)
if (!linkedPage) {
brokenLinks.links.push({ 'broken link': link, reason: 'linked page not found' })
continue
}
- // finding the linked page isn't enough if it's a github.com page; also need to check versions
- if (linkedPage.relativePath.startsWith('github')) {
- const linkedPageVersions = getApplicableVersions(linkedPage.versions, linkedPage.relativePath)
-
- if (!linkedPageVersions.includes(version) && $(internalLink).attr('class') !== 'dotcom-only') {
- brokenLinks.links.push({ 'broken link': link, reason: `${version} not found in linked page versions`, 'linked page': linkedPage.fullPath })
- continue
- }
- }
-
// don't check anchors on developers content
if (linkedPage.relativePath.match(/^(rest|graphql|developers)/)) continue
diff --git a/lib/find-page-in-version.js b/lib/find-page-in-version.js
new file mode 100644
index 0000000000..21f55f02c3
--- /dev/null
+++ b/lib/find-page-in-version.js
@@ -0,0 +1,22 @@
+const findPage = require('./find-page')
+const getApplicableVersions = require('./get-applicable-versions')
+
+module.exports = function findPageInVersion (href, pages, redirects, languageCode, version, isDotcomOnly = false) {
+ // findPage() will throw an error if an English page can't be found
+ const page = findPage(href, pages, redirects, languageCode)
+ if (!page) return null
+
+ // if the link is on the homepage, return the page as soon as it's found
+ if (version === 'homepage') return page
+
+ // if the link is dotcom-only, return the page as soon as it's found
+ if (isDotcomOnly) return page
+
+ // otherwise, get the versions that the found page is available in
+ const applicableVersions = getApplicableVersions(page.versions, page.fullPath)
+
+ // return null if the found page's available versions do not include the specified version
+ if (!applicableVersions.includes(version)) return null
+
+ return page
+}
diff --git a/lib/liquid-tags/link.js b/lib/liquid-tags/link.js
index c5160081a2..b583b006ec 100644
--- a/lib/liquid-tags/link.js
+++ b/lib/liquid-tags/link.js
@@ -4,8 +4,7 @@ const Liquid = require('liquid')
const liquid = new Liquid.Engine()
const { getPathWithLanguage } = require('../path-utils')
const LiquidTag = require('./liquid-tag')
-const findPage = require('../find-page')
-const getApplicableVersions = require('../get-applicable-versions')
+const findPageInVersion = require('../find-page-in-version')
// This class supports a set of link tags. Each tag expects one parameter, a language-agnostic href:
//
@@ -56,20 +55,11 @@ module.exports = class Link extends LiquidTag {
fullPath = getPathWithLanguage(fullPath, ctx.currentLanguage)
// find the page based on the full path
- const page = findPage(fullPath, ctx.pages, ctx.redirects, ctx.currentLanguage)
-
- // workaround for localized links that can't be found because they are not in sync
- if (!page) return ''
-
- // get versions of the found page
- const applicableVersions = getApplicableVersions(page.versions, fullPath)
-
- // check whether the page versions include the current version
- const shouldLinkRenderInCurrentVersion = applicableVersions.includes(ctx.currentVersion)
+ const page = findPageInVersion(fullPath, ctx.pages, ctx.redirects, ctx.currentLanguage, ctx.currentVersion)
// if found page should NOT render in current version, return early with an empty string
// also return if it's a hidden link on a non-hidden page (hidden links on hidden pages are OK)
- if (!shouldLinkRenderInCurrentVersion || (page.hidden && !ctx.page.hidden)) {
+ if (!page || (page.hidden && !ctx.page.hidden)) {
return ''
}
diff --git a/lib/path-utils.js b/lib/path-utils.js
index f180d28f07..02e75aab1d 100644
--- a/lib/path-utils.js
+++ b/lib/path-utils.js
@@ -22,19 +22,30 @@ function getVersionedPathWithoutLanguage (href, version) {
// example: enterprise-server@2.22 or free-pro-team@latest
let versionFromPath = getVersionStringFromPath(href)
- // if versionFromPath doesn't match any current versions, this may be an old
- // versioned path that should be converted to new versioned path. Examples:
- // OLD: /enterprise/2.22/admin/installation OR /enterprise/admin/installation
- // NEW: /enterprise-server@2.22/admin/installation
- // OLD: /desktop/installing-and-configuring-github-desktop
- // NEW: /free-pro-team@latest/desktop/installing-and-configuring-github-desktop
+ // if the version found is not a currently supported version...
+ let productObjectFromPath
if (!Object.keys(allVersions).includes(versionFromPath)) {
- href = getNewVersionedPath(href)
- versionFromPath = getVersionStringFromPath(href)
+ // first check if the first segment is instead a current product;
+ // example: /admin/foo or /desktop/foo
+ productObjectFromPath = allProducts[versionFromPath]
+
+ // if so, add the first supported version for that product to the href
+ if (productObjectFromPath) {
+ href = path.join('/', productObjectFromPath.versions[0], href)
+ versionFromPath = productObjectFromPath.versions[0]
+ } else {
+ // otherwise, this may be an old path that should be converted to new path;
+ // OLD: /enterprise/2.22/admin/installation OR /enterprise/admin/installation
+ // NEW: /enterprise-server@2.22/admin/installation
+ href = getNewVersionedPath(href)
+ versionFromPath = getVersionStringFromPath(href)
+ }
}
- // derive the product from the path (e.g., github or admin) and get corresponding object
- const productObjectFromPath = getProductObjectFromPath(href)
+ // if not previously found, derive the product object from the path (e.g., github or admin)
+ if (!productObjectFromPath) {
+ productObjectFromPath = getProductObjectFromPath(href)
+ }
// if the product's versions don't include the specified version, nothing to change!
if (productObjectFromPath && !productObjectFromPath.versions.includes(version)) {
diff --git a/lib/site-tree.js b/lib/site-tree.js
index 60d45a42d1..aefc093b8e 100644
--- a/lib/site-tree.js
+++ b/lib/site-tree.js
@@ -1,6 +1,5 @@
const path = require('path')
-const findPage = require('./find-page')
-const getApplicableVersions = require('./get-applicable-versions')
+const findPageInVersion = require('./find-page-in-version')
const products = Object.values(require('../lib/all-products'))
const { getVersionedPathWithoutLanguage } = require('./path-utils')
const languageCodes = Object.keys(require('./languages'))
@@ -39,7 +38,10 @@ module.exports = async function buildSiteTree (pages, site, redirects) {
product.href = item.href
// find the product TOC page and get TOC items
- const page = findPage(item.href, pages, redirects, languageCode)
+ const page = findPageInVersion(item.href, pages, redirects, languageCode, version)
+
+ // skip if page can't be found in this version
+ if (!page) return
product.categories = buildCategoriesTree(page.tocItems, item.href, pages, redirects, version, languageCode)
@@ -69,17 +71,13 @@ function buildCategoriesTree (tocItems, productHref, pages, redirects, version,
category.href = versionedCategoryHref
// find the category TOC page and get its TOC items
- const page = findPage(categoryHref, pages, redirects, languageCode)
+ const page = findPageInVersion(categoryHref, pages, redirects, languageCode, version)
- // skip if translated page can't be found
- if (!page && languageCode !== 'en') return
+ // skip if page can't be found in this version
+ if (!page) return
category.title = page.shortTitle || page.title
- if (!getApplicableVersions(page.versions, page.fullPath).includes(version)) {
- return
- }
-
// support standalone pages at the category level, like actions/quickstart.md
if (!page.tocItems) {
category.standalone = true
@@ -120,18 +118,14 @@ function buildMaptopicsTree (tocItems, categoryHref, pages, redirects, version,
// we already have access to the child articles via the category TOC items
// but we still need the page to get the available versions
- const page = findPage(maptopicHref, pages, redirects, languageCode)
+ const page = findPageInVersion(maptopicHref, pages, redirects, languageCode, version)
- // skip if translated page can't be found
- if (!page && languageCode !== 'en') return
+ // skip if page can't be found in this version
+ if (!page) return
// if this is not a maptopic, return early
if (!page.mapTopic) return
- if (!getApplicableVersions(page.versions, page.fullPath).includes(version)) {
- return
- }
-
const childArticles = getChildArticles(tocItems, item.href)
maptopic.title = page.title
@@ -163,17 +157,13 @@ function buildArticlesTree (tocItems, categoryHref, pages, redirects, version, l
const versionedArticleHref = getVersionedPathWithoutLanguage(articleHref, version)
article.href = versionedArticleHref
- const page = findPage(articleHref, pages, redirects, languageCode)
+ const page = findPageInVersion(articleHref, pages, redirects, languageCode, version)
- // skip if translated page can't be found
- if (!page && languageCode !== 'en') return
+ // skip if page can't be found in this version
+ if (!page) return
article.title = page.shortTitle || page.title
- if (!getApplicableVersions(page.versions, page.fullPath).includes(version)) {
- return
- }
-
articleTree[versionedArticleHref] = article
})
diff --git a/middleware/featured-links.js b/middleware/featured-links.js
index ed58a26948..eeaba4fa34 100644
--- a/middleware/featured-links.js
+++ b/middleware/featured-links.js
@@ -1,5 +1,4 @@
-const findPage = require('../lib/find-page')
-const getApplicableVersions = require('../lib/get-applicable-versions')
+const findPageInVersion = require('../lib/find-page-in-version')
const { getVersionedPathWithLanguage } = require('../lib/path-utils')
// this middleware adds properties to the context object
@@ -30,14 +29,9 @@ async function getLinkData (rawLinks, context) {
? getVersionedPathWithLanguage(link.href, context.currentVersion, context.currentLanguage)
: getVersionedPathWithLanguage(link, context.currentVersion, context.currentLanguage)
- const linkedPage = findPage(href, context.pages, context.redirects, context.currentLanguage)
+ const linkedPage = findPageInVersion(href, context.pages, context.redirects, context.currentLanguage, context.currentVersion)
if (!linkedPage) continue
- const applicableVersions = getApplicableVersions(linkedPage.versions, linkedPage.fullPath)
-
- // skip link if this is not the homepage and the link's versions do not include the current version
- if (context.currentVersion !== 'homepage' && !applicableVersions.includes(context.currentVersion)) continue
-
const opts = { textOnly: true, encodeEntities: true }
links.push({
diff --git a/package.json b/package.json
index 66f45b24db..574f4d0f7b 100644
--- a/package.json
+++ b/package.json
@@ -77,6 +77,7 @@
"webpack-cli": "^3.3.12"
},
"devDependencies": {
+ "@actions/core": "^1.2.6",
"ajv": "^6.11.0",
"async": "^3.2.0",
"await-sleep": "0.0.1",
|