-
Notifications
You must be signed in to change notification settings - Fork 931
107 lines (104 loc) · 3.99 KB
/
_link_check.yml
File metadata and controls
107 lines (104 loc) · 3.99 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
on:
workflow_call:
inputs:
ref:
type: string
required: true
jobs:
lint-urls:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-url-lint') }}
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Fetch base ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
else
git fetch --no-tags --depth=1 origin "${{ github.event.before }}"
fi
- name: Lint URLs
run: |
./scripts/lint_urls.sh $(
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
fi
) || {
echo
echo "URL lint failed."
echo "If this is a transient outage, you can bypass it by adding the \`skip-url-lint\` label to your PR."
echo "Or add \`@lint-ignore\` somewhere on the same line as the URL you want to skip checking."
exit 1
}
lint-xrefs:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-xref-lint') }}
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Fetch base ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
else
git fetch --no-tags --depth=1 origin "${{ github.event.before }}"
fi
- name: Lint cross-references
run: |
./scripts/lint_xrefs.sh $(
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
fi
) || {
echo
echo "Xref lint failed."
echo "If this is a transient outage, you can bypass it by adding the \`skip-xref-lint\` label to your PR."
echo "Or add \`@lint-ignore\` somewhere on the same line as the reference you want to skip checking."
exit 1
}
lint-file-size:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Fetch base ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
else
git fetch --no-tags --depth=1 origin "${{ github.event.before }}"
fi
- name: Lint file sizes
run: |
chmod +x ./scripts/lint_file_size.sh
./scripts/lint_file_size.sh $(
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
fi
) || {
echo
echo "File size lint failed: some files exceed the 1 MB limit."
echo "If you really need large files, consider using Git LFS or storing them elsewhere."
echo "If you really need to get unblocked and check in the file, can add it to the EXCEPTIONS list in scripts/lint_file_size.sh."
exit 1
}