-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-shacl-ts-unique-branch.yml
More file actions
62 lines (48 loc) · 1.6 KB
/
generate-shacl-ts-unique-branch.yml
File metadata and controls
62 lines (48 loc) · 1.6 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: Generate TypeScript from SHACL - new branch
on:
# push:
# paths:
# - "shapes/**" # only trigger when SHACL files change
# pull_request:
# paths:
# - "shapes/**"
workflow_dispatch: # allows manual trigger from GitHub UI
jobs:
generate-ts:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
- name: Clone CLI repo
run: git clone https://github.com/theodi/shacl-shape-converter-typescript.git
- name: Install and build CLI
run: |
cd shacl-shape-converter-typescript/shacl-ts-generator
npm install
npm run build
npm link
- name: Ensure output folder exists
run: mkdir -p objects
- name: Generate TypeScript classes
run: npx shacl-converter shapes objects
- name: Commit generated TypeScript classes
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
# Create a branch for the auto-generated code
BRANCH="auto/shacl-ts-${GITHUB_RUN_ID}"
git checkout -B $BRANCH
# Stage the objects folder
git add objects
# Only commit if changes exist
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Auto-generate TypeScript classes from SHACL shapes"
# Push the branch back to the repo
git push origin $BRANCH