Skip to content

Commit 4fb4e14

Browse files
committed
Add check-spelling
0 parents  commit 4fb4e14

1 file changed

Lines changed: 185 additions & 0 deletions

File tree

.github/workflows/spelling.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: Check Spelling
2+
3+
# Comment management is handled through a secondary job, for details see:
4+
# https://github.com/check-spelling/check-spelling/wiki/Feature%3A-Restricted-Permissions
5+
#
6+
# `jobs.comment-push` runs when a push is made to a repository and the `jobs.spelling` job needs to make a comment
7+
# (in odd cases, it might actually run just to collapse a comment, but that's fairly rare)
8+
# it needs `contents: write` in order to add a comment.
9+
#
10+
# `jobs.comment-pr` runs when a pull_request is made to a repository and the `jobs.spelling` job needs to make a comment
11+
# or collapse a comment (in the case where it had previously made a comment and now no longer needs to show a comment)
12+
# it needs `pull-requests: write` in order to manipulate those comments.
13+
14+
# Updating pull request branches is managed via comment handling.
15+
# For details, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-expect-list
16+
#
17+
# These elements work together to make it happen:
18+
#
19+
# `on.issue_comment`
20+
# This event listens to comments by users asking to update the metadata.
21+
#
22+
# `jobs.update`
23+
# This job runs in response to an issue_comment and will push a new commit
24+
# to update the spelling metadata.
25+
#
26+
# `with.experimental_apply_changes_via_bot`
27+
# Tells the action to support and generate messages that enable it
28+
# to make a commit to update the spelling metadata.
29+
#
30+
# `with.ssh_key`
31+
# In order to trigger workflows when the commit is made, you can provide a
32+
# secret (typically, a write-enabled github deploy key).
33+
#
34+
# For background, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-with-deploy-key
35+
36+
# SARIF reporting
37+
#
38+
# Access to SARIF reports is generally restricted (by GitHub) to members of the repository.
39+
#
40+
# Requires enabling `security-events: write`
41+
# and configuring the action with `use_sarif: 1`
42+
#
43+
# For information on the feature, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-SARIF-output
44+
45+
# Minimal workflow structure:
46+
#
47+
# on:
48+
# push:
49+
# ...
50+
# pull_request_target:
51+
# ...
52+
# jobs:
53+
# # you only want the spelling job, all others should be omitted
54+
# spelling:
55+
# # remove `security-events: write` and `use_sarif: 1`
56+
# # remove `experimental_apply_changes_via_bot: 1`
57+
# ... otherwise, adjust the `with:` as you wish
58+
59+
# on.pull_request(_target).edited is only needed for with.check_commit_messages: title | description
60+
61+
on:
62+
push:
63+
branches:
64+
- '**'
65+
tags-ignore:
66+
- '**'
67+
pull_request_target:
68+
branches:
69+
- '**'
70+
types:
71+
- 'edited'
72+
- 'opened'
73+
- 'reopened'
74+
- 'synchronize'
75+
issue_comment:
76+
types:
77+
- 'created'
78+
79+
permissions: {}
80+
81+
jobs:
82+
spelling:
83+
name: Check Spelling
84+
permissions:
85+
contents: read
86+
pull-requests: read
87+
actions: read
88+
security-events: write
89+
outputs:
90+
followup: ${{ steps.spelling.outputs.followup }}
91+
runs-on: ubuntu-latest
92+
if: ${{ (contains(github.event_name, 'pull_request') && github.event.pull_request.state == 'open') || github.event_name == 'push' }}
93+
concurrency:
94+
group: spelling-${{ github.event.pull_request.number || github.ref }}
95+
# note: If you use only_check_changed_files, you do not want cancel-in-progress
96+
cancel-in-progress: true
97+
steps:
98+
- name: check-spelling
99+
id: spelling
100+
uses: check-spelling/check-spelling@prerelease
101+
with:
102+
suppress_push_for_open_pull_request: ${{ github.actor != 'dependabot[bot]' && 1 }}
103+
checkout: true
104+
check_file_names: 1
105+
check_commit_messages: commits, title, description
106+
spell_check_this: check-spelling/spell-check-this@prerelease
107+
post_comment: 0
108+
report-timing: 1
109+
warnings: bad-regex,binary-file,deprecated-feature,ignored-expect-variant,large-file,limited-references,no-newline-at-eof,noisy-file,non-alpha-in-dictionary,token-is-substring,unexpected-line-ending,whitespace-in-dictionary,minified-file,unsupported-configuration,no-files-to-check,unclosed-block-ignore-begin,unclosed-block-ignore-end
110+
experimental_apply_changes_via_bot: 1
111+
use_sarif: 1
112+
check-images: 1
113+
extra_dictionary_limit: 20
114+
allow-hunspell: false
115+
load-config-from: |
116+
{
117+
"pr-base-keys": [
118+
"check_extra_dictionaries",
119+
"dictionary_source_prefixes",
120+
"extra_dictionaries",
121+
""
122+
],
123+
"pr-trusted-keys": [
124+
""
125+
],
126+
"": []
127+
}
128+
129+
comment-push:
130+
name: Report (Push)
131+
# If your workflow isn't running on push, you can remove this job
132+
runs-on: ubuntu-slim
133+
needs: spelling
134+
permissions:
135+
actions: read
136+
contents: write
137+
if: (success() || failure()) && needs.spelling.outputs.followup && github.event_name == 'push'
138+
steps:
139+
- name: comment
140+
uses: check-spelling/check-spelling@prerelease
141+
with:
142+
spell_check_this: check-spelling/spell-check-this@prerelease
143+
task: ${{ needs.spelling.outputs.followup }}
144+
145+
comment-pr:
146+
name: Report (PR)
147+
# If you workflow isn't running on pull_request*, you can remove this job
148+
runs-on: ubuntu-slim
149+
needs: spelling
150+
permissions:
151+
actions: read
152+
pull-requests: write
153+
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
154+
steps:
155+
- name: comment
156+
uses: check-spelling/check-spelling@prerelease
157+
with:
158+
spell_check_this: check-spelling/spell-check-this@prerelease
159+
task: ${{ needs.spelling.outputs.followup }}
160+
experimental_apply_changes_via_bot: 1
161+
162+
update:
163+
name: Update PR
164+
permissions:
165+
contents: write
166+
pull-requests: write
167+
actions: read
168+
runs-on: ubuntu-slim
169+
if: ${{
170+
github.event_name == 'issue_comment' &&
171+
github.event.issue.pull_request &&
172+
contains(github.event.comment.body, '@check-spelling-bot') &&
173+
contains(github.event.comment.body, 'apply') &&
174+
contains(github.event.comment.body, 'https://')
175+
}}
176+
concurrency:
177+
group: spelling-update-${{ github.event.issue.number }}
178+
cancel-in-progress: false
179+
steps:
180+
- name: apply spelling updates
181+
uses: check-spelling/check-spelling@prerelease
182+
with:
183+
experimental_apply_changes_via_bot: 1
184+
checkout: true
185+
ssh_key: '${{ secrets.CHECK_SPELLING }}'

0 commit comments

Comments
 (0)