Skip to content

Commit 72f506c

Browse files
committed
Merge branch 'main' of github.com:github/docs-internal into exclude-some-links
2 parents c6cb579 + 9434940 commit 72f506c

4 files changed

Lines changed: 145 additions & 7 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Link Checker: Dotcom'
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
jobs:
8+
see_if_should_skip:
9+
continue-on-error: true
10+
runs-on: ubuntu-latest
11+
# Map a step output to a job output
12+
outputs:
13+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
14+
steps:
15+
- id: skip_check
16+
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
17+
with:
18+
cancel_others: 'false'
19+
github_token: ${{ github.token }}
20+
paths: '[".github/workflows/link-check-dotcom.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
21+
build:
22+
needs: see_if_should_skip
23+
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
24+
steps:
25+
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
26+
# Even if if doesn't do anything
27+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
28+
name: Checkout
29+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
30+
31+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
32+
name: Setup node
33+
uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e
34+
with:
35+
node-version: 14.x
36+
37+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
38+
name: Install
39+
run: npm ci
40+
41+
## TODO
42+
# - if: ${{ github.repository == 'github/docs-internal' && needs.see_if_should_skip.outputs.should_skip != 'true' }}
43+
# name: Clone early access
44+
# run: npm run heroku-postbuild
45+
# env:
46+
# DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
47+
# GIT_BRANCH: ${{ github.ref }}
48+
49+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
50+
name: Build
51+
run: npm run build
52+
53+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
54+
name: 'Link check: Dotcom'
55+
env:
56+
DOCS_VERSION: 'dotcom'
57+
run: npm run link-check
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Link Checker
1+
name: 'Link Checker: GitHub AE'
22

33
on:
44
workflow_dispatch:
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
cancel_others: 'false'
1919
github_token: ${{ github.token }}
20-
paths: '[".github/workflows/link-check-test.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
20+
paths: '[".github/workflows/link-check-ghae.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
2121
build:
2222
needs: see_if_should_skip
2323
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
@@ -51,5 +51,7 @@ jobs:
5151
run: npm run build
5252

5353
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
54-
name: Link check
54+
name: 'Link check: GitHub AE'
55+
env:
56+
DOCS_VERSION: 'github-ae'
5557
run: npm run link-check
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Link Checker: Enterprise Server'
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
jobs:
8+
see_if_should_skip:
9+
continue-on-error: true
10+
runs-on: ubuntu-latest
11+
# Map a step output to a job output
12+
outputs:
13+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
14+
steps:
15+
- id: skip_check
16+
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
17+
with:
18+
cancel_others: 'false'
19+
github_token: ${{ github.token }}
20+
paths: '[".github/workflows/link-check-ghes.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
21+
build:
22+
needs: see_if_should_skip
23+
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
24+
steps:
25+
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
26+
# Even if if doesn't do anything
27+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
28+
name: Checkout
29+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
30+
31+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
32+
name: Setup node
33+
uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e
34+
with:
35+
node-version: 14.x
36+
37+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
38+
name: Install
39+
run: npm ci
40+
41+
## TODO
42+
# - if: ${{ github.repository == 'github/docs-internal' && needs.see_if_should_skip.outputs.should_skip != 'true' }}
43+
# name: Clone early access
44+
# run: npm run heroku-postbuild
45+
# env:
46+
# DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
47+
# GIT_BRANCH: ${{ github.ref }}
48+
49+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
50+
name: Build
51+
run: npm run build
52+
53+
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
54+
name: 'Link check: Enterprise Server'
55+
env:
56+
DOCS_VERSION: 'enterprise-server'
57+
run: npm run link-check

script/check-internal-links.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
const linkinator = require('linkinator')
44
const checker = new linkinator.LinkChecker()
5-
const { deprecated } = require('../lib/enterprise-server-releases')
5+
const { deprecated, latest } = require('../lib/enterprise-server-releases')
66
const englishRoot = 'http://localhost:4002/en'
7+
const allowedVersions = ['dotcom', 'enterprise-server', 'github-ae']
78

89
// [start-readme]
910
//
10-
// This script runs in CI via GitHub Action to check all *internal* links in English content,
11-
// not including deprecated Enterprise Server content. This is different from script/check-english-links.js,
12-
// which checks *all* links in the site, both internal and external, and is much slower.
11+
// This script runs in CI via GitHub Action to check all *internal* links in English content for a
12+
// given version, not including deprecated Enterprise Server content. This is different from
13+
// script/check-english-links.js, which checks *all* links in the site, both internal and external,
14+
// and is much slower.
1315
//
1416
// If you want to run it locally, you must have a local server running. You can use `npm run link-check`.
1517
//
@@ -35,10 +37,30 @@ const config = {
3537
]
3638
}
3739

40+
// Customize config for specific versions
41+
if (process.env.DOCS_VERSION === 'dotcom') {
42+
// If Dotcom, skip Enterprise Server and GitHub AE links
43+
config.linksToSkip.push('^.*/enterprise-server@.*$', '^.*/enterprise/.*$', '^.*/github-ae@latest.*$')
44+
} else if (process.env.DOCS_VERSION === 'enterprise-server') {
45+
// If Enterprise Server, skip links that are not Enterprise Server links
46+
config.path = `${englishRoot}/enterprise-server@${latest}`
47+
config.linksToSkip.push('^((?!enterprise-server@).)*$')
48+
} else if (process.env.DOCS_VERSION === 'github-ae') {
49+
// If GitHub AE, skip links that are not GitHub AE links
50+
config.path = `${englishRoot}/github-ae@latest`
51+
config.linksToSkip.push('^((?!github-ae@latest).)*$')
52+
}
53+
3854
main()
3955

4056
async function main () {
57+
process.env.DOCS_VERSION && allowedVersions.includes(process.env.DOCS_VERSION)
58+
? console.log(`Checking internal links for version ${process.env.DOCS_VERSION}!\n`)
59+
: console.log('Checking internal links for all versions!\n')
60+
61+
console.time('check')
4162
const result = (await checker.check(config)).links
63+
console.timeEnd('check')
4264

4365
const brokenLinks = result
4466
.filter(link => link.state === 'BROKEN')

0 commit comments

Comments
 (0)