-
Notifications
You must be signed in to change notification settings - Fork 66.8k
164 lines (144 loc) · 6.22 KB
/
link-check-internal.yml
File metadata and controls
164 lines (144 loc) · 6.22 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: 'Link Check: Internal'
on:
schedule:
- cron: '20 16 * * 1' # Run every Monday at 16:20 UTC / 8:20 PST — link & content quality theme
workflow_dispatch:
inputs:
version:
description: 'Version to check (e.g., free-pro-team@latest, enterprise-server@3.19)'
type: string
required: true
language:
description: 'Language to check (e.g., en, es, ja)'
type: string
required: true
default: 'en'
permissions:
contents: read
jobs:
# Determine which version/language combos to run
setup-matrix:
if: github.repository == 'github/docs-internal'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/node-npm-setup
- name: Set matrix
id: set-matrix
run: |
if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then
# Manual run: use the provided version and language
echo "matrix={\"include\":[{\"version\":\"${INPUT_VERSION}\",\"language\":\"${INPUT_LANGUAGE}\"}]}" >> $GITHUB_OUTPUT
else
# Scheduled run: English free-pro-team + English latest enterprise-server
LATEST_GHES=$(npx tsx -e "import { latest } from './src/versions/lib/enterprise-server-releases'; console.log(latest)")
echo "matrix={\"include\":[{\"version\":\"free-pro-team@latest\",\"language\":\"en\"},{\"version\":\"enterprise-server@${LATEST_GHES}\",\"language\":\"en\"}]}" >> $GITHUB_OUTPUT
fi
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_LANGUAGE: ${{ inputs.language }}
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
check-internal-links:
if: github.repository == 'github/docs-internal'
needs: setup-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
env:
# Disable Elasticsearch for faster warmServer
ELASTICSEARCH_URL: ''
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/node-npm-setup
- name: Install dependencies
run: npm ci
# Clone translations if not English
- name: Clone translations
if: matrix.language != 'en'
uses: ./.github/actions/clone-translations
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
- name: Check internal links
env:
VERSION: ${{ matrix.version }}
LANGUAGE: ${{ matrix.language }}
CHECK_ANCHORS: true
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: npm run check-links-internal
- name: Upload report artifact
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: link-report-${{ matrix.version }}-${{ matrix.language }}
path: artifacts/link-report-*.md
retention-days: 5
if-no-files-found: ignore
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
# Create combined report after all matrix jobs complete
create-report:
if: always() && github.repository == 'github/docs-internal'
needs: [setup-matrix, check-internal-links]
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Download all artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
path: reports
pattern: link-report-*
merge-multiple: true
- name: Combine reports
id: combine
run: |
# Check if any reports exist
if ls reports/*.md 1> /dev/null 2>&1; then
echo "has_reports=true" >> $GITHUB_OUTPUT
# Combine all markdown reports
echo "# Internal Links Report" > combined-report.md
echo "" >> combined-report.md
echo "> [!NOTE]" >> combined-report.md
echo "> **No action needed right now.** The link checker is being actively worked on and may produce false positives. You can safely ignore this report for now. We'll let you know when it's reliable." >> combined-report.md
echo "" >> combined-report.md
echo "Generated: $(date -u +'%Y-%m-%d %H:%M UTC')" >> combined-report.md
echo "[Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> combined-report.md
echo "" >> combined-report.md
for report in reports/*.md; do
echo "---" >> combined-report.md
cat "$report" >> combined-report.md
echo "" >> combined-report.md
done
else
echo "has_reports=false" >> $GITHUB_OUTPUT
echo "No broken link reports generated - all links valid!"
fi
- name: Create issue if broken links found
if: steps.combine.outputs.has_reports == 'true'
uses: peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v5
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
repository: github/docs-content
title: '🔗 Broken Internal Links Report'
content-filepath: combined-report.md
labels: broken link report
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}