Skip to content

Commit 534a4fa

Browse files
authored
Merge pull request #9 from nkdAgility/add-custom-config-to-action
Add ability to customsie the configFile!
2 parents a5c8ea7 + 0f12623 commit 534a4fa

File tree

3 files changed

+45
-31
lines changed

3 files changed

+45
-31
lines changed

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ Repository is created for the support of any languages that you need for spell c
66

77
## Features
88

9-
- Customizable configuration of spell checking using [Aspell](http://aspell.net) and [Hunspell](http://hunspell.github.io) due to [docs](https://facelessuser.github.io/pyspelling/configuration/)
10-
- Support any formats of file to check
9+
- Customizable configuration of spell checking using [Aspell](http://aspell.net) and [Hunspell](http://hunspell.github.io) due to [docs](https://facelessuser.github.io/pyspelling/configuration/)
10+
- Support for any formats of file to check
1111
- Supports any languages from the list for [Aspell](https://ftp.gnu.org/gnu/aspell/dict/0index.html) and any languages for [Hunspell](https://en.wikipedia.org/wiki/Hunspell).
1212

1313
## Configuration
1414

15-
1. First you have to add a configuration for the spelling checker
16-
2. Create a file named: `.spellcheck.yml` or `.spellcheck.yaml`, do note if both files exist the prior will have precedence. Do note the recommendation is _hidden_ files since these configuration files are not first rate citizens of your repository
17-
3. Paste the contents of the outlined example, which is a configuration for Markdown, useful for your README file
15+
1. First, you have to add a configuration for the spelling checker.
16+
2. Create a file named: `.spellcheck.yml` or `.spellcheck.yaml`. Note that if both files exist, `.spellcheck.yml` will take precedence. Hidden files are recommended for configuration since these files are not primary content of your repository.
17+
3. Paste the contents of the outlined example, which is a configuration for Markdown, useful for your README file.
1818

19-
Do note that this action requires the contents of the repository, so it is recommended used with [the Checkout action][actioncheckout].
19+
Do note that this action requires the contents of the repository, so it is recommended to use it with [the Checkout action][actioncheckout].
2020

21-
You have to define this part in your workflow, since it not a part of the action itself.
21+
You have to define this part in your workflow, as it is not a part of the action itself.
2222

23-
Example:
23+
### Example Workflow
2424

2525
```yaml
26-
# This is workflow for spell checking using PySpelling lib (https://pypi.org/project/pyspelling/)
26+
# This is a workflow for spell checking using PySpelling lib (https://pypi.org/project/pyspelling/)
2727
name: Spellcheck
2828
# Controls when the action will run.
2929
on:
@@ -46,15 +46,17 @@ jobs:
4646
- uses: actions/checkout@v2
4747
- uses: igsekor/[email protected]
4848
name: Spellcheck
49+
with:
50+
configFile: '.my-custom-config.yml' # Optional field
4951
```
5052
51-
Note the step: `- uses: actions/checkout@master`
52-
This file must live in a the `.github/workflows/` directory.
53-
For example, it could be `.github/workflows/spellcheck.yml`
53+
### Optional Field
5454
55-
## Checking For Bad Spelling
55+
The action supports an optional `configFile` input parameter to specify a custom configuration file name. By default, it looks for `.spellcheck.yml` or `.spellcheck.yaml` files. You can override this default by providing a `configFile` input in the workflow as shown above.
5656

57-
The GitHub Action helps you make sure _most_ spelling errors do not make it into your repository. You can however check your spelling prior to committing and pushing to your repository.
57+
### Checking For Bad Spelling
58+
59+
The GitHub Action helps you make sure _most_ spelling errors do not make it into your repository. You can, however, check your spelling prior to committing and pushing to your repository.
5860

5961
This simply uses the contents of our spelling toolchain:
6062

@@ -67,14 +69,14 @@ Misspelled words:
6769
!!!Spelling check failed!!!
6870
```
6971

70-
And at some point we get:
72+
And at some point, you get:
7173

7274
```bash
7375
$ pyspelling -c .spellcheck.yml
7476
Spelling check passed :)
7577
```
7678

77-
Now we should be good to go.
79+
Now you should be good to go.
7880

7981
Do note you could also use the `entrypoint.sh`, which is the script used in the Docker image.
8082

@@ -97,4 +99,5 @@ The original author of this GitHub Action is Igor Korovchenko (@igsekor)
9799

98100
## Copyright and License
99101

100-
This repository is licensed under the MIT license.
102+
This repository is licensed under the MIT license.
103+

action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
name: 'GitHub Spellcheck'
2-
description: 'A Github Action that spell checks for any languages by aspell / hunspell'
2+
description: 'A GitHub Action that spell checks for any languages by aspell / hunspell'
33
author: Igor Korovchenko
44
branding:
55
color: green
66
icon: type
7+
inputs:
8+
configFile:
9+
description: 'The configuration file to use for spellchecking'
10+
required: true
11+
default: '.pyspelling.yml'
712
runs:
813
using: docker
9-
image: 'docker://igsekor/pyspelling-any'
14+
image: 'docker://igsekor/pyspelling-any'
15+
args:
16+
- ${{ inputs.configFile }}

entrypoint.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#!/bin/sh -l
22

3-
SPELLCHECK_CONFIG_FILE=''
4-
5-
if [ -f "./.spellcheck.yml" ]; then
6-
SPELLCHECK_CONFIG_FILE=".spellcheck.yml"
7-
elif [ -f "./.spellcheck.yaml" ]; then
8-
SPELLCHECK_CONFIG_FILE=".spellcheck.yaml"
9-
elif [ -f "./spellcheck.yml" ]; then
10-
SPELLCHECK_CONFIG_FILE="spellcheck.yml"
11-
else
12-
SPELLCHECK_CONFIG_FILE="spellcheck.yaml"
3+
# Default to an empty config file if not specified
4+
SPELLCHECK_CONFIG_FILE="${INPUT_CONFIGFILE}"
5+
6+
# If no config file is provided, fallback to predefined file names
7+
if [ -z "$SPELLCHECK_CONFIG_FILE" ]; then
8+
if [ -f "./.spellcheck.yml" ]; then
9+
SPELLCHECK_CONFIG_FILE=".spellcheck.yml"
10+
elif [ -f "./.spellcheck.yaml" ]; then
11+
SPELLCHECK_CONFIG_FILE=".spellcheck.yaml"
12+
elif [ -f "./spellcheck.yml" ]; then
13+
SPELLCHECK_CONFIG_FILE="spellcheck.yml"
14+
else
15+
SPELLCHECK_CONFIG_FILE="spellcheck.yaml"
16+
fi
1317
fi
1418

1519
echo ""
@@ -36,8 +40,8 @@ pyspelling --config $SPELLCHECK_CONFIG_FILE
3640

3741
EXITCODE=$?
3842

39-
test $EXITCODE -gt 1 && echo "\033[91Spelling check action failed, please check diagnostics\033[39m";
43+
test $EXITCODE -gt 1 && echo "\033[91mSpelling check action failed, please check diagnostics\033[39m"
4044

41-
test $EXITCODE -eq 1 && echo "\033[91mFiles in repository contain spelling errors\033[39m";
45+
test $EXITCODE -eq 1 && echo "\033[91mFiles in repository contain spelling errors\033[39m"
4246

4347
exit $EXITCODE

0 commit comments

Comments
 (0)