Create Ontology #1
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: Create Ontology | |
on: | |
workflow_dispatch: | |
inputs: | |
schema_name: | |
description: 'The name of the schema("standard" for standard schema)' | |
default: '' | |
schema_version: | |
description: 'The schema version to convert' | |
required: true | |
pr_title: | |
description: 'Pull Request Title' | |
required: true | |
default: 'Create ontology from hed-schemas/main' | |
pr_description: | |
description: 'Pull Request Description' | |
required: true | |
default: 'Create ontology from hed-schemas/main' | |
jobs: | |
manage-branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ontology | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Checkout schemas | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
path: 'hed-schemas' | |
repository: 'hed-standard/hed-schemas' | |
- name: Delete old provisional branch if needed | |
run: | | |
# Check if the provisional branch exists on the remote | |
EXISTS=$(git ls-remote --heads origin provisional | wc -l) | |
if [ "$EXISTS" -ne 0 ]; then | |
git push origin --delete provisional | |
echo "Provisional branch deleted." | |
else | |
echo "Provisional branch does not exist on remote, skipping delete." | |
fi | |
- name: Create new provisional branch from main | |
run: | | |
git checkout main | |
git pull | |
git checkout -b provisional | |
git push origin provisional | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: pip install git+https://github.com/hed-standard/hed-python.git@develop | |
- name: Create ontology | |
run: | | |
hed_create_ontology hed-schemas ${{ github.event.inputs.schema_name }} ${{ github.event.inputs.schema_version }} | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git add src/ontology/* | |
git commit -m "Automatically creating ontology for ${{ github.event.inputs.schema_name }} ${{ github.event.inputs.schema_version }}" | |
git push origin provisional | |
- name: Create provisional to main PR | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr create --base main --head provisional --title "${{ github.event.inputs.pr_title }}" --body "${{ github.event.inputs.pr_description }}" |