-
Notifications
You must be signed in to change notification settings - Fork 5
74 lines (64 loc) · 2.54 KB
/
generate_yaml_model.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
74
# Generates linkml yaml schema from metadata in googlesheets using schemasheets
name: generating yaml file
on:
workflow_dispatch:
inputs:
model:
description: 'model name'
required: true
type: string
jobs:
generate_libgen_yaml:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- 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]
pip install git+https://github.com/brain-bican/bkbit.git
pip install git+https://github.com/linkml/schemasheets.git@649af7e1
- name: Other installations
run: |
sudo apt-get update
sudo apt-get install -y build-essential git wget curl
# Check if download-dir exists; if not, create it
- name: Check if download-dir exists
run: |
if [ ! -d "linkml-schema/source_${{ inputs.model }}/gsheet_output" ]; then
echo "Directory does not exist. Making directory"
mkdir -p linkml-schema/source_${{ inputs.model }}/gsheet_output
fi
# Check if gsheet.yaml exists
- name: Check if gsheet.yaml exists
run: |
if [ ! -f "linkml-schema/source_${{ inputs.model }}/gsheet.yaml" ]; then
echo "gsheet.yaml does not exist. Exiting"
exit 1
fi
# Generate yaml model
- name: Generate yaml model
run: |
cd linkml-schema
bkbit schema2model -o ${{ inputs.model }}.yaml --gsheet --gsheet-download-dir source_${{ inputs.model }}/gsheet_output source_${{ inputs.model }}/gsheet.yaml --no-inlined
cd ..
# Generate unique branch name
- name: Generate unique branch name
run: |
BRANCH_NAME="autogenerated-yaml-$(date +%Y%m%d%H%M%S)"
echo "Branch created: $BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
# Create a pull request
- name: Create a Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
commit-message: "Generate new version of the linkml model for ${{ inputs.model }}"
branch: ${{ env.BRANCH_NAME }}
title: "Auto PR: ${{ inputs.model }}.yaml generated from google spreadsheets using schemasheets"
body: "This PR adds a autogenerated ${{ inputs.model }}.yaml file."
base: main