Skip to content

Ontology submission: MAO #53

Ontology submission: MAO

Ontology submission: MAO #53

name: Ontology Submission
on:
issues:
types: [opened] # run only when a new issue is created
jobs:
export:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Extract form data
id: form
uses: actions/github-script@v6
with:
script: |
const issue = context.payload.issue;
// Map headings exactly to your desired column titles
const headingMap = {
'Title': 'Title',
'Prefix': 'Prefix',
'Version': 'Version',
'Created': 'Created',
'Description': 'Description',
'URI': 'uri',
'Reference': 'Reference',
'Linked-to ontologies AECO': 'Linked-to ontologies AECO',
'Linked-to ontologies UPPER': 'Linked-to ontologies UPPER',
'Linked-to ontologies OTHER': 'Linked-to ontologies OTHER DOMAINS'
};
const lines = issue.body.split(/\r?\n/);
const data = {};
let currentKey = null;
for (const ln of lines) {
const heading = ln.match(/^###\s+(.*)/); // “### Heading”
if (heading) {
const raw = heading[1].trim();
currentKey = headingMap[raw] ?? raw; // normalise heading
continue;
}
if (!currentKey) continue;
if (ln.trim() === '') continue; // skip blank line
data[currentKey] = ln.trim(); // first non-blank line = value
currentKey = null; // reset
}
if (Object.keys(data).length === 0) {
core.setFailed('No form fields found – is this the correct template?');
}
core.setOutput('json', JSON.stringify(data, null, 2));
- name: Save JSON
run: |
mkdir -p data/submissions
echo '${{ steps.form.outputs.json }}' \
> "data/submissions/submission_${{ github.event.issue.number }}.json"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pandas openpyxl
- name: JSON → Excel
run: |
python create_submission_excel.py \
"data/submissions/submission_${{ github.event.issue.number }}.json" \
"data/submissions/submission_${{ github.event.issue.number }}.xlsx"
- name: Commit submission files
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "data/submissions/submission_${{ github.event.issue.number }}.json"
git add "data/submissions/submission_${{ github.event.issue.number }}.xlsx"
git commit -m "Add submission #${{ github.event.issue.number }}" || echo "Nothing to commit"
git push