-
Notifications
You must be signed in to change notification settings - Fork 3
87 lines (72 loc) · 2.97 KB
/
collect_submissions.yml
File metadata and controls
87 lines (72 loc) · 2.97 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
permissions:
contents: write
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