DIG-1522: change cohort to program #556
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
name: Docs | |
on: | |
pull_request: | |
branches: | |
- develop | |
paths: | |
- "chord_metadata_service/mohpackets/schemas/**" | |
- "chord_metadata_service/mohpackets/models.py" | |
- "chord_metadata_service/mohpackets/permissible_values.py" | |
jobs: | |
generate-moh-schema: | |
name: Update MoH schema | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
ref: ${{ github.head_ref }} | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: python -m pip install -r requirements/base.txt | |
- name: Generate new schema.json | |
run: | | |
export DJANGO_SETTINGS_MODULE=config.settings.base | |
echo "CACHE_DURATION = 0" >> config/settings/base.py | |
echo "AGGREGATE_COUNT_THRESHOLD = 5" >> config/settings/base.py | |
python manage.py export_openapi_schema --api chord_metadata_service.mohpackets.apis.core.api | python -m json.tool > chord_metadata_service/mohpackets/docs/schemas/schema.json | |
- name: Install widdershins | |
run: npm install -g widdershins | |
- name: Convert schema to OpenAPI documentation | |
run: | | |
npx widdershins ./chord_metadata_service/mohpackets/docs/schemas/schema.json -o ./chord_metadata_service/mohpackets/docs/schemas/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true | |
- name: Install PyYAML | |
run: pip install PyYAML | |
- name: Convert schema.json to schema.yml | |
run: python -c 'import json, yaml; json.load(open("chord_metadata_service/mohpackets/docs/schemas/schema.json")); print(yaml.dump(json.load(open("chord_metadata_service/mohpackets/docs/schemas/schema.json"))))' > chord_metadata_service/mohpackets/docs/schemas/schema.yml | |
- name: Update schemas | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Update schemas | |
file_pattern: "chord_metadata_service/mohpackets/docs/schemas/schema.json chord_metadata_service/mohpackets/docs/schemas/schema.md chord_metadata_service/mohpackets/docs/schemas/schema.yml" | |
- name: Get SHA commit of schema.json | |
id: get-sha | |
run: echo "SHA=$(git log -1 --format=%H chord_metadata_service/mohpackets/docs/schemas/schema.json)" >> $GITHUB_ENV | |
- name: Write SHA to schema_version.txt | |
run: echo ${{ env.SHA }} > chord_metadata_service/mohpackets/docs/schema_version.txt | |
- name: Commit updated schema_version.txt | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Update schema version | |
file_pattern: "chord_metadata_service/mohpackets/docs/schema_version.txt" |