Fix workflows #10
Workflow file for this run
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
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
generate_doc: | |
name: Generate the documentation from the JSON Schemas | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-20.04"] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=${GITHUB_HEAD_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Pull current branch | |
run: | | |
git fetch | |
git checkout -b ${{ steps.extract_branch.outputs.branch }} origin/${{ steps.extract_branch.outputs.branch }} | |
- name: Install json-schema-for-humans | |
run: pip install json-schema-for-humans | |
- name: Create documentation directory | |
run: mkdir -p _docs | |
- name: Generate the documentation | |
run: | | |
generate-schema-doc --config template_name=md_nested ./.schema/controller.json ./_docs/controller.md | |
generate-schema-doc --config template_name=md_nested ./.schema/manufacturer.json ./_docs/manufacturer.md | |
generate-schema-doc --config template_name=md_nested ./.schema/category.json ./_docs/category.md | |
- name: Commit files | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add * | |
if ! git diff-index --quiet HEAD; then | |
git commit -m "Update documentation" -a | |
fi | |
- name: push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.extract_branch.outputs.branch }} | |
validate: | |
name: Validate JSON Files against schemas | |
runs-on: ubuntu-latest | |
needs: | |
- generate_doc | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Validate Category JSON | |
uses: dsanders11/json-schema-validate-action@v1.1.0 | |
with: | |
schema: ".schema/category.json" | |
files: "*/config.json" | |
- name: Validate Manufacturer JSON | |
uses: dsanders11/json-schema-validate-action@v1.1.0 | |
with: | |
schema: ".schema/manufacturer.json" | |
files: "*/*/config.json" | |
- name: Validate Controller JSON | |
uses: dsanders11/json-schema-validate-action@v1.1.0 | |
with: | |
schema: ".schema/controller.json" | |
files: "*/*/*/config.json" |