Skip to content

Commit

Permalink
Merge pull request #3 from OrRosenblatt/changes-before-publishing
Browse files Browse the repository at this point in the history
Changes before publishing
  • Loading branch information
OrRosenblatt authored Nov 12, 2019
2 parents 5786b0a + f6bb3aa commit 6441c34
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# Github Action: Validate JSON
Validate JSON with a single GitHub Action.
A GitHub Action that validates JSON files based on a JSON Schema.

This project uses [`ajv`](https://github.com/epoberezkin/ajv), fast JSON schema validator, to perform the validation.

## Usage

### Inputs

- `schema`: Relative file path under the repository of a JSON schema file to validate the other JSON files with. Default is: `'./schema.json'`.
- `jsons`: One or more relative file paths under the repository (seperated by comma) of the JSON files to validate with the schema provided.

> Note: `schema` is **required**, otherwise default will be used.
### Outputs

- `invalid`: One or more of relative file paths of the invalid JSON files, found in the repository (seperated by comma).

### Example Workflow

An example `.github/workflows/validate.yml` workflow to run JSON validation on the repository:

```yaml
name: Validate JSON

on: [pull_request]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: OrRosenblatt/validate-json-action@v1
- with:
schema: /path/to/schema.json
jsons: /path/to/file.json,/path/to/another/file.json
```
## TODOs
- [x] Initial validation action
- [ ] Github workflow screenshots
- [ ] Support `jsons` in PRs
- [ ] Support `schema` & `jsons` by external reference (from S3/GitHub/etc...)
- [ ] Support `delimiter` input
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ description: 'GitHub Action: Validate JSON'
author: 'Or Rosenblatt'
inputs:
schema:
description: 'Path in the repository to load the schema from.'
description: 'Relative file path under the repository of a JSON schema file to validate the other JSON files with.'
required: true
default: './schema.json'
json:
description: 'Path in the repository of the JSON files to validate. Can also be a list of paths, seperated by comma.'
description: 'One or more relative file paths under the repository (seperated by comma) of the JSON files to validate with the schema provided.'
required: true
outputs:
invalid:
description: 'List of the invalid file paths, seperated by comma.'
description: 'One or more of relative file paths of the invalid JSON files, found in the repository (seperated by comma).'
runs:
using: 'node12'
main: 'lib/main.js'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "validate-json-action",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"description": "A Github action for validating JSON",
"main": "lib/main.js",
Expand Down

0 comments on commit 6441c34

Please sign in to comment.