diff --git a/.github/workflows/spectral.yml b/.github/workflows/spectral.yml index 5fc2dfe..b0fe2be 100644 --- a/.github/workflows/spectral.yml +++ b/.github/workflows/spectral.yml @@ -7,10 +7,10 @@ jobs: name: Spectral checks runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2 - name: Spectral checks uses: ./ with: file_glob: ./**/*.yml repo_token: ${{ secrets.GITHUB_TOKEN }} - spectral_ruleset: 'spectral:oas' + spectral_ruleset: .spectral.yml diff --git a/.spectral.yml b/.spectral.yml new file mode 100644 index 0000000..df81522 --- /dev/null +++ b/.spectral.yml @@ -0,0 +1 @@ +extends: spectral:oas diff --git a/README.md b/README.md index 90c1fb6..12c2ad3 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,11 @@ This action uses [Spectral](https://github.com/stoplightio/spectral) from [Stopl ![](./image.png) -## Install +## Usage -```json +See [action.yml](action.yml) + +```yaml name: Run Spectral on Pull Requests on: @@ -17,16 +19,23 @@ jobs: name: Run Spectral runs-on: ubuntu-latest steps: - # Check out the repository - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 # Run Spectral - uses: stoplightio/spectral-action@v0.5.5 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file_glob: doc/api/*.yaml + spectral_ruleset: 'spectral:oas' ``` -## Configuration +### Inputs -Spectral Action will respect your [Spectral Rulesets](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/getting-started/rulesets.md), which can be defined, extended, and overriden by placing `.spectral.yml` in the root of your repository. +- **repo_token:** _[Required]_ GitHub token to access the repository containing the files to lint +- **file_glob:** Pattern describing the set of files to lint. Defaults to `*.oas.{json,yml,yaml}`. (_Note:_ Pattern syntax is documented in the [fast-glob](https://www.npmjs.com/package/fast-glob) package documentation) +- **spectral_ruleset:** Ruleset to load in Spectral. Defaults to `spectral:oas` +## Configuration +Spectral Action will respect your [Spectral Rulesets](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/getting-started/rulesets.md), which can be defined, extended, and overriden by placing `.spectral.yml` in the root of your repository. diff --git a/action.yml b/action.yml index 78c73d3..df202f1 100644 --- a/action.yml +++ b/action.yml @@ -12,7 +12,7 @@ inputs: default: 'spectral:oas' repo_token: required: true - description: Ruleset file to load in Spectral + description: GitHub token to access the repository containing the files to lint runs: using: docker image: Dockerfile diff --git a/package.json b/package.json index a6739ee..757768e 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@actions/core": "^1.2.3", "@actions/github": "^2.1.1", "@stoplight/json": "^3.5.1", - "@stoplight/spectral": "^5.1.0", + "@stoplight/spectral": "^5.3.0", "fast-glob": "^3.2.2", "fp-ts": "^2.5.3", "io-ts": "^2.1.2",