Skip to content

Commit

Permalink
Merge pull request #4 from jjasghar/add_env_support
Browse files Browse the repository at this point in the history
add env var support
  • Loading branch information
stevemar committed Oct 20, 2020
2 parents 4e888b0 + cb83507 commit 57bd06b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ To use this function in your repository perform the following steps:
2. Create a file in `.github/workflows/` and paste the following code:

```yaml

on:
push:
branches:
Expand All @@ -52,9 +51,10 @@ To use this function in your repository perform the following steps:
- name: Checking out our code
uses: actions/checkout@master
- name: Remove the problematic words
uses: jjasghar/actions-words-really-matter@v2.0.1
uses: jjasghar/actions-words-really-matter@v2.1.0
- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: Remove problematic words
Expand All @@ -65,10 +65,19 @@ To use this function in your repository perform the following steps:
[1]: https://github.com/jjasghar/actions-words-really-matter
- name: Check outputs
run: |
echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"
echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}"
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
```
## Override or add to the dictionary
If you want to override some of our values or just add your own then pass them as environment variables that start with `WORDS_`. For example, add this block to your GitHub Action workflow

```yaml
env:
WORDS_foo: bar
```

## Tips

If you want to re-build this with debug logs, just add this line to the `Dockerfile`:
Expand Down
11 changes: 10 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,29 @@ declare -A dict

[[ -n ${DEBUG} ]] && set -eox

# switch to a directory if it is specified
if ! [ -z $1 ]; then
if [[ -d $1 ]]
then
cd $1
fi
fi

echo "Looking for problematic words in $(pwd)"

# create an initial dictionary
counter=0
dict=( ["master"]="leader" ["slave"]="follower"
["blacklist"]="denylist" ["whitelist"]="allowlist"
["grandfathered"]="legacy" ["guys"]="folks")

# additionally, populate the dictionary with any
# environment variables that start with "WORDS_"
# this will also override the ones above
for var in "${!WORDS_@}"; do
key=$(echo $var | cut -d _ -f 2)
dict["$key"]="${!var}"
done

# Loop over the dictionary
for i in "${!dict[@]}"
do
Expand Down

0 comments on commit 57bd06b

Please sign in to comment.