-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (53 loc) · 1.73 KB
/
convert_excel_to_json.yml
File metadata and controls
62 lines (53 loc) · 1.73 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
name: Convert Excel to JSON
on:
push:
paths:
- 'data/Ontologies_forRepo.xlsx'
- 'excel_to_json.py'
- '.github/workflows/*.yml'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: json-${{ github.ref }}
cancel-in-progress: true
jobs:
convert:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set timestamp
run: echo "TS=$(date -u +'%Y%m%dT%H%M%SZ')" >> "$GITHUB_ENV"
- name: Convert Excel to JSON
env:
IN: data/Ontologies_forRepo.xlsx
OUT_LIVE: data/Ontologies_forRepo.json
run: |
mkdir -p output
python excel_to_json.py --input "$IN" --output "$OUT_LIVE" --sheet Data
python excel_to_json.py --input "$IN" --output "output/Ontologies_forRepo_${TS}.json" --sheet Data
- name: Commit and push JSON safely
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add data/Ontologies_forRepo.json output/Ontologies_forRepo_*.json || true
if git diff --quiet --cached; then
echo "No changes to commit."
exit 0
fi
git commit -m "Auto convert Excel to JSON"
git pull --rebase origin "$BRANCH_NAME"
git push origin HEAD:"$BRANCH_NAME"