Add stable_identifier_version #101
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: | |
push: | |
branches: | |
- "**" | |
- "!main" | |
paths: | |
- "src/**/*.json" | |
- ".github/workflows/generate-python.yml" | |
jobs: | |
generate-python: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate token | |
id: generate_token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.DAPLA_BOT_APP_ID }} | |
private-key: ${{ secrets.DAPLA_BOT_PRIVATE_KEY }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.generate_token.outputs.token }} | |
- name: Configure Git | |
run: | | |
git config user.name "dapla-bot[bot]" | |
git config user.email "143391972+dapla-bot[bot]@users.noreply.github.com" | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11.5 | |
- name: Install pipx | |
run: | | |
python -m pip install --upgrade pipx | |
python -m pipx ensurepath | |
- name: Install datamodel-codegen | |
run: | | |
python -m pipx install datamodel-code-generator==0.24.2 | |
- name: Generate Python | |
run: > | |
datamodel-codegen | |
--input-file-type jsonschema | |
--input src/metadata-container-json-schema.json | |
--output-model-type pydantic_v2.BaseModel | |
--use-default | |
--use-one-literal-as-default | |
--use-subclass-enum | |
--use-standard-collections | |
--target-python-version 3.10 | |
--output generated/python/datadoc_model/datadoc_model/model.py | |
- name: Check for modified files | |
id: git-check | |
run: echo modified=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi) >> $GITHUB_OUTPUT | |
- name: Commit | |
if: steps.git-check.outputs.modified == 'true' | |
run: | | |
git add -A | |
git commit -m '[GENERATE] Pydantic models from JSON Schema' | |
- name: Push | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ steps.generate_token.outputs.token }} | |
branch: ${{ github.ref }} |