Skip to content

Commit

Permalink
feat: support multiple files (#701)
Browse files Browse the repository at this point in the history
* feat: support multiple files

* fix: set IFS

* fix: use while loop

* ci: fix multiple output

* docs: update README
  • Loading branch information
suzuki-shunsuke committed Aug 28, 2024
1 parent 72f92fe commit 36a15b8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,28 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./
- name: Test a single file
uses: ./
with:
config_file_path: renovate.json
- name: Test multiple files
uses: ./
with:
config_file_path: |
renovate.json
tests/renovate.json
- id: files
run: |
set -euo pipefail
files=$(git ls-files | grep renovate.json)
# https://stackoverflow.com/a/74232400
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
{
echo "files<<$EOF"
echo "$files"
echo "$EOF"
} >> "$GITHUB_OUTPUT"
- name: Pass files through output
uses: ./
with:
config_file_path: ${{ steps.files.outputs.files }}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@ By default, the following files are validated.
* renovate.json5
* .renovaterc

If you want to validate multiple files, you can pass multile lines.
Leading spaces on each line are removed.

```yaml
with:
config_file_path: |
default.json
foo.json
```
You can pass `config_file_path` through output command.

```yaml
- id: files
run: |
set -euo pipefail
files=$(git ls-files | grep renovate.json)
# https://stackoverflow.com/a/74232400
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
{
echo "files<<$EOF"
echo "$files"
echo "$EOF"
} >> "$GITHUB_OUTPUT"
- name: Pass files through output
uses: suzuki-shunsuke/[email protected]
with:
config_file_path: ${{ steps.files.outputs.files }}
```

## Output

Nothing.
Expand Down
11 changes: 9 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ inputs:
- renovate.json
- renovate.json5
- .renovaterc
You can specify multiple files by multiple lines.
required: false
runs:
using: composite
Expand All @@ -50,8 +52,13 @@ runs:
fi
if [ -n "$CONFIG_FILE_PATH" ]; then
echo "===> RENOVATE_CONFIG_FILE=\"$CONFIG_FILE_PATH\" npx --yes --package \"$pkg\" -c \"renovate-config-validator $opts\"" >&2
RENOVATE_CONFIG_FILE="$CONFIG_FILE_PATH" npx --yes --package "$pkg" -c "renovate-config-validator $opts"
while read -r file; do
if [ -z "$file" ]; then
continue
fi
echo "===> RENOVATE_CONFIG_FILE=\"$file\" npx --yes --package \"$pkg\" -c \"renovate-config-validator $opts\"" >&2
RENOVATE_CONFIG_FILE="$file" npx --yes --package "$pkg" -c "renovate-config-validator $opts"
done < <(echo "$CONFIG_FILE_PATH")
exit 0
fi
Expand Down
5 changes: 5 additions & 0 deletions tests/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"config:best-practices"
]
}

0 comments on commit 36a15b8

Please sign in to comment.