DIG-1355: Sonchau/UUID with fk #17
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: | |
types: [review_requested, ready_for_review] | |
jobs: | |
first_job: | |
name: Regenerate schema | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: python -m pip install -r requirements/base.txt | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Create package.json file | |
run: | | |
echo '{"name": "my-project", "version": "1.0.0"}' > package.json | |
- name: Install npm | |
run: npm install | |
- name: Install widdershins | |
run: npm install -g widdershins | |
- name: Install PyYAML | |
run: pip install PyYAML | |
- name: Generate new schema.json | |
run: | | |
export DJANGO_SETTINGS_MODULE=config.settings.base | |
python manage.py export_openapi_schema --api chord_metadata_service.mohpackets.apis.core.api | python -m json.tool > chord_metadata_service/mohpackets/docs/schema.json | |
- name: Convert schema to OpenAPI documentation | |
run: | | |
npx widdershins ./chord_metadata_service/mohpackets/docs/schema.json -o ./chord_metadata_service/mohpackets/docs/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true | |
- name: Convert schema.json to schema.yml | |
run: python -c 'import json, yaml; json.load(open("chord_metadata_service/mohpackets/docs/schema.json")); print(yaml.dump(json.load(open("chord_metadata_service/mohpackets/docs/schema.json"))))' > chord_metadata_service/mohpackets/docs/schema.yml | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
file_pattern: 'chord_metadata_service/mohpackets/docs/schema.*' | |
commit_message: Regenerate schema | |
# - name: Commit and push changes to schema.json | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# const fs = require('fs'); | |
# const { Octokit } = require('@octokit/rest'); | |
# const octokit = new Octokit({ request: { fetch: fetch, }, auth: "${{ secrets.GITHUB_TOKEN }}" }); | |
# const { commitAndPushChanges } = require("./.github/commitFile.js"); | |
# await commitAndPushChanges('schema.json', `${{ github.head_ref }}`, fs, octokit, context); | |
# second_job: | |
# name: Adding schema SHA | |
# needs: first_job | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Check out repo | |
# uses: actions/checkout@v4 | |
# - name: Git pull to update the repository | |
# run: git pull origin ${{ github.head_ref }} | |
# - name: Install Python | |
# uses: actions/setup-python@v4 | |
# with: | |
# python-version: "3.12" | |
# - name: Set up Node.js | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: 18 | |
# - name: Create package.json file | |
# run: | | |
# echo '{"name": "my-project", "version": "1.0.0"}' > package.json | |
# - name: Install npm | |
# run: npm install | |
# - name: Install widdershins | |
# run: npm install -g widdershins | |
# - name: Install PyYAML | |
# run: pip install PyYAML | |
# - name: Convert schema to OpenAPI documentation | |
# run: | | |
# npx widdershins ./chord_metadata_service/mohpackets/docs/schema.json -o ./chord_metadata_service/mohpackets/docs/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true | |
# - name: Convert schema.json to schema.yml | |
# run: python -c 'import json, yaml; json.load(open("chord_metadata_service/mohpackets/docs/schema.json")); print(yaml.dump(json.load(open("chord_metadata_service/mohpackets/docs/schema.json"))))' > chord_metadata_service/mohpackets/docs/schema.yml | |
# - name: Update schema with last SHA | |
# run: | | |
# REPO_NAME=${{ github.repository }} | |
# HEAD_REF=${{ github.head_ref }} | |
# SHA=$(git rev-parse HEAD) | |
# DOCS_PATH="chord_metadata_service/mohpackets/docs/" | |
# SCHEMA_PATHS=( | |
# "${DOCS_PATH}schema.json" | |
# "${DOCS_PATH}schema.yml" | |
# "${DOCS_PATH}schema.md" | |
# ) | |
# for path in "${SCHEMA_PATHS[@]}"; do | |
# sed -i "s|This is the RESTful API for the MoH Service.|This is the RESTful API for the MoH Service. Based on https://raw.githubusercontent.com/$REPO_NAME/$SHA/$path|" "$path" | |
# done | |
# - uses: stefanzweifel/git-auto-commit-action@v5 | |
# with: | |
# file_pattern: 'chord_metadata_service/mohpackets/docs/schema.*' | |
# commit_message: Update schema SHA | |
# - name: Commit and push changes | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# const fs = require('fs'); | |
# const { Octokit } = require('@octokit/rest'); | |
# const octokit = new Octokit({ request: { fetch: fetch, }, auth: "${{ secrets.GITHUB_TOKEN }}" }); | |
# const { commitAndPushChanges } = require("./.github/commitFile.js"); | |
# await commitAndPushChanges('schema.json', `${{ github.head_ref }}`, fs, octokit, context); | |
# await commitAndPushChanges('schema.yml', `${{ github.head_ref }}`, fs, octokit, context); | |
# await commitAndPushChanges('schema.md', `${{ github.head_ref }}`, fs, octokit, context); |