Skip to content

Commit 8e09e3b

Browse files
authored
feat: Add support for multiple config files (#9)
* fixes #8 - remove hard coded config file location - trigger on any `.yml` file in `.circleci/` - update readme for details on specifying config files This is possible because by default, `circleci config validate` looks for a config file in `.circleci/config.yml`. * fix grammar * Use equal separated args over space separated
1 parent 7b1bd92 commit 8e09e3b

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.pre-commit-hooks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
- id: circleci_validate
22
name: Validate CircleCI config
3-
description: This hook validate CircleCI config
3+
description: This hook validates CircleCI config
44
entry: circleci_validate.sh
55
language: script
6-
files: .circleci/config.yml
6+
files: .circleci/.*.yml
77
pass_filenames: false

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $ cat .pre-commit-config.yaml
1414

1515
If you wish to pass additional args to circleci_validate, you can specify
1616
them in the config. See `circleci config validate --help` for accepted args.
17+
You must use the form `--arg=value`, not `--arg value`.
1718

1819
For example, to set an org-slug:
1920
```bash
@@ -23,7 +24,18 @@ $ cat .pre-commit-config.yaml
2324
hooks:
2425
- id: circleci_validate
2526
args:
26-
- --org-slug my/organization
27+
- --org-slug=my/organization
28+
```
29+
30+
Or specify a custom config file:
31+
```bash
32+
$ cat .pre-commit-config.yaml
33+
- repo: https://github.com/zahorniak/pre-commit-circleci.git
34+
rev: v0.5 # Ensure this is the latest tag, comparing to the Releases tab
35+
hooks:
36+
- id: circleci_validate
37+
args:
38+
- .circleci/continue_config.yml
2739
```
2840

2941
## 3. Install hook

circleci_validate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ then
1212
exit 1
1313
fi
1414

15-
if ! eMSG=$(circleci config validate "$@" -c .circleci/config.yml); then
15+
if ! eMSG=$(circleci config validate "$@"); then
1616
echo "CircleCI Configuration Failed Validation."
1717
echo "${eMSG}"
1818
exit 1

0 commit comments

Comments
 (0)