Keep your examples in sync with your Action
Last month I added a few more GitHub Actions to the Marketplace and while working on them found that it was easy to forget to update my examples as the implementation of the Action evolved
Last month I added a few more GitHub Actions to the Marketplace and while working on them found that it was easy to forget to update my examples as the implementation of the Action evolved.
So, what started as a small script to automatically validate the examples against the action.yaml quickly grew into its own action:
Introducing the Actions Example Checker
The Actions Example Checker is a simple action you can add to your repository. It will scan for all action.yaml files and extract the metadata. It will then search through all markdown files in your repo and extract all YAML script blocks:
```yaml
- uses: your/action@version
```Any examples that reference your action will be checked against the schema.
Additionally, you can add a action.schema.yaml with extended metadata about each input, like: allowed values, datatype, regex. I've got a few more plans with this, but for now it's purely used to check the assigned values in your examples.
Sample workflow
In order to add the Actions example checker to your repo, add this workflow:
name: Validate Documentation
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions: {}
jobs:
validate-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
sparse-checkout: |
**/action.yaml
**/action.yml
**/action.schema.yaml
**/action.schema.yml
**/*.md
sparse-checkout-cone-mode: false
- uses: jessehouwing/actions-example-checker@ea0821955c7ecf2c98e5b184054ba31486914a7b # v0.0.4
token: ${{ secrets.GITHUB_TOKEN }}Example schemas
I've already added schema validation to most of my own actions, they may be able to help you setup your own:
- actions-example-checker/action.schema.yaml
- actions-semver-checker/action.schema.yaml
- actions-dependency-submission/action.schema.yaml
- azdo-marketplace/action.schema.yaml
Let me know if you find this useful!