1+ name : Reusable workflow for generating other formats
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ model_name :
7+ description : ' A name of the model, without the .yaml extension'
8+ required : true
9+ type : string
10+
11+ permissions :
12+ contents : write
13+
14+ jobs :
15+ generate :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : Checkout this repository
19+ uses : actions/checkout@v3
20+ with :
21+ fetch-depth : 0
22+ repository : ${{ github.event.pull_request.head.repo.full_name }}
23+ ref : ${{ github.event.pull_request.head.ref }}
24+
25+ - name : Set up Python
26+ uses : actions/setup-python@v4
27+ with :
28+ python-version : 3.9
29+
30+ - name : Install the required python packages
31+ run : python -m pip install .[test]
32+
33+ - name : Other installations
34+ run : |
35+ sudo apt-get update
36+ sudo apt-get install -y build-essential git wget curl
37+
38+ - name : Generate other model representations
39+ run : |
40+ cd linkml-schema
41+ name=${{ inputs.model_name }};
42+ echo "Processing $name model...";
43+ gen-json-schema ${name}.yaml > ../json-schema-autogen/${name}.json;
44+ # generating jsonld context and removing generation_date field to avoid constant updates
45+ gen-jsonld-context ${name}.yaml > ../jsonld-context-autogen/${name}.context.jsonld;
46+ sed -i "/generation_date/d" ../jsonld-context-autogen/${name}.context.jsonld;
47+ gen-pydantic ${name}.yaml > ../models_py-autogen/${name}.py;
48+ if [ ${name} = "library_generation" ] || [ ${name} = "genome_annotation" ]; then
49+ echo "Fixing erdiagrams for $name";
50+ python ../utils/fix_and_create_erdiagram.py;
51+ else
52+ gen-erdiagram ${name}.yaml > ../erdiagram-autogen/${name}.md;
53+ fi
54+ cd ..
55+
56+ - name : Adding other model representations to git
57+ run : |
58+ name=${{ inputs.model_name }};
59+ git config --global user.name "[email protected] " 60+ git config --global user.email "Github Actions"
61+ git branch
62+ git diff
63+ git add json-schema-autogen/${name}.json
64+ git add jsonld-context-autogen/${name}.context.jsonld
65+ git add models_py-autogen/${name}.py
66+ git add erdiagram-autogen/${name}.md
67+ if ! git diff --quiet HEAD; then
68+ git commit -m "generate another formats for ${name} model"
69+ git pull --rebase # to avoid conflicts with different wf runs
70+ git push
71+ else
72+ echo "No changes to commit"
73+ fi
0 commit comments