forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 2.38 KB
/
Copy pathlink-check-on-pr.yml
File metadata and controls
68 lines (58 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: 'Link Check: On PR'
# **What it does**: Checks internal links in changed content files.
# **Why we have it**: To catch broken links before they're merged.
# **Who does it impact**: Docs content.
on:
workflow_dispatch:
# merge_group:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
issues: write
# Cancel in-progress runs for the same PR
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
check-links:
name: Check links
runs-on: ubuntu-latest
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# Fetch 2 commits so tj-actions/changed-files can diff without extra API calls
fetch-depth: 2
- uses: ./.github/actions/node-npm-setup
- uses: ./.github/actions/get-docs-early-access
if: ${{ github.repository == 'github/docs-internal' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
with:
files: |
content/**/*.md
data/**/*.md
- name: Check links in changed files
if: steps.changed-files.outputs.any_changed == 'true'
env:
FILES_CHANGED: ${{ steps.changed-files.outputs.all_changed_files }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SHOULD_COMMENT: ${{ secrets.DOCS_BOT_PAT_BASE != '' }}
FAIL_ON_FLAW: true
# Cross-page anchor checking is on, but non-blocking during rollout: broken
# anchors are reported in the PR comment without failing the build. Flip
# FAIL_ON_ANCHOR_FLAW to true once false-positive/perf rates look clean.
CHECK_ANCHORS: true
FAIL_ON_ANCHOR_FLAW: false
ENABLED_LANGUAGES: en
run: npm run check-links-pr
- name: No content changes
if: steps.changed-files.outputs.any_changed != 'true'
run: echo "No content files changed. Skipping link check."