Skip to content

Commit c6f052b

Browse files
Rahul-4480vjdhama
authored andcommitted
add: spell & grammar check ci job
1 parent 8f04b2c commit c6f052b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/spellcheck.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Spell Check and Grammar Check
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths: ["content/blog/*"]
7+
8+
jobs:
9+
spellcheck:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Get changed files
19+
id: changed-files
20+
uses: tj-actions/changed-files@v44
21+
with:
22+
files: |
23+
content/blog/**.md
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.x'
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install openai==0.28
34+
35+
- name: Run spell check
36+
id: spellcheck
37+
env:
38+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
39+
run: |
40+
ALL_CHANGED_FILES='${{ steps.changed-files.outputs.all_changed_files }}'
41+
python .github/scripts/spellcheck.py $ALL_CHANGED_FILES
42+
continue-on-error: true
43+
44+
- name: Post comment for pull request
45+
if: github.event_name == 'pull_request'
46+
uses: mshick/add-pr-comment@v2
47+
with:
48+
message-path: spell_check_result_with_lines.json
49+
50+
- name: Fail the job if spell check failed
51+
if: steps.spellcheck.outcome == 'failure'
52+
run: exit 1

0 commit comments

Comments
 (0)