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