-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new action to validate contribution to the bonita documen…
…tation content (#115) Create action to validate the contribution follow our documentation guidelines. * Adding forbidden pattern check (ex: static link to https://www.documentation.bontiasoft.com) * Validate if some attributes are put in updated file (ex: :description: tag to help us for the SEO)
- Loading branch information
1 parent
ddfde5f
commit 2d675f0
Showing
19 changed files
with
15,495 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ |
34 changes: 34 additions & 0 deletions
34
packages/pr-antora-content-guidelines-checker/.eslintrc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"overrides": [ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"files": [ | ||
".eslintrc.{js,cjs}" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
} | ||
} | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"github" | ||
], | ||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# PR Antora content guidelines checker | ||
|
||
This action checks the diff in a PR, and fails if one or more of the set criteria isn't met. | ||
If action failed, a comment with details will be written in the Pull Request | ||
|
||
## Using this action | ||
|
||
See [action.yml](./action.yml) for the detailed list of inputs and outputs. | ||
|
||
### Permissions | ||
|
||
Set the `pull-requests` permission to `write` to allow the action to post comments on the PR. | ||
Set the `github-token` if you want to use a personal access token, by default the value is `${{ secrets.GITHUB_TOKEN }}` | ||
|
||
``` | ||
name: Check PR content | ||
on: [pull_request] | ||
jobs: | ||
check_contribution: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
pull-requests: write # post comments when the Pull Request title doesn't match the "Guidelines" rules | ||
steps: | ||
- name: Check contribution guidelines | ||
uses: bonitasoft/actions/packages/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} // optional | ||
attributes-to-check: ':description:' | ||
files-to-check: 'adoc' | ||
forbidden-pattern-to-check: 'https://documentation.bonitasoft.com, link:' | ||
``` | ||
|
||
An example is also provided in [bonita-labs-doc repository](https://github.com/bonitasoft/bonita-labs-doc/blob/master/.github/workflows/check-contribution.yml). | ||
|
||
## Steps | ||
|
||
### Attributes Checking | ||
|
||
For each file updated in the pull request, check if the files contains the value of `forbidden-pattern-to-check` properties and failed if at least one attribute is missing | ||
|
||
### Forbidden Pattern | ||
|
||
For each file updated in the pull request, check if the files contains the value of `attributes-to-check` properties and failed if pattern is exist. | ||
|
||
## Development | ||
|
||
**Node version**: see the [.nvmrc](.nvmrc) file | ||
|
||
As for all JavaScript actions, the `dist` folder must be committed. | ||
|
||
So when changing the JS code or when updating the production dependencies (that are bundled in the final distribution), | ||
please regenerate the content of the `dist` folder. | ||
* Run `npm ci && npm run package:all` | ||
* Commit the dist folder | ||
|
||
|
||
## License | ||
|
||
This is released under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: 'PR Antora content guidelines checker' | ||
description: 'Checks files updated on PR are following the contribution guideline for an Antora documentation content.' | ||
inputs: | ||
github-token: | ||
description: 'The token used to create Pull Request comment when the contribution does not follow requirements' | ||
required: false | ||
default: ${{ github.token }} | ||
files-to-check: | ||
description: 'Comma-separated list of file extension to check in the modified files. (ex: adoc, md, txt)`' | ||
required: false | ||
default: 'adoc' | ||
attributes-to-check: | ||
description: 'Comma-separated list of attributes to check in the modified files. (ex: :description:, :alias:), keep empty to skip this check.`' | ||
default: '' | ||
required: false | ||
forbidden-pattern-to-check: | ||
description: 'Comma-separated list of forbidden pattern to check in the modified files. (ex: http://documentation.mydomain,link:), keep empty to skip this check.' | ||
default: '' | ||
required: false | ||
|
||
runs: | ||
using: 'node20' | ||
main: 'dist/index.js' |
Oops, something went wrong.