Skip to content

Commit f308e8a

Browse files
author
AREMA Ontology Bot
committed
refactor: consolidate github actions into one flow, refactor to use releases instead of commits to main
1 parent 5e52ef4 commit f308e8a

8 files changed

Lines changed: 282 additions & 195 deletions

File tree

.env.dist

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
# SKOHub Documentation
12
BASEURL=/docs
2-
ONTOLOGY_SPARQL_ENDPOINT=
3-
GRAPHDB_USERNAME=
4-
GRAPHDB_PASSWORD=
5-
GRAPH_URI=
63

7-
# Fuseki Configuration (required for docker-compose)
4+
# Production Fuseki Endpoint (used by GitHub Actions)
5+
FUSEKI_SPARQL_ENDPOINT=
6+
FUSEKI_USERNAME=
7+
FUSEKI_PASSWORD=
8+
GRAPH_URI=https://ontology.atlas-regenmat.ch/
9+
10+
# GitHub Configuration (for triggering workflows)
11+
GITHUB_TOKEN=
12+
GITHUB_REPOSITORY=sdsc-ordes/arema-ontology
13+
14+
# Local Development Fuseki (docker-compose)
815
FUSEKI_URL=http://localhost:3030/arema/data
9-
FUSEKI_USERNAME=admin
10-
FUSEKI_PASSWORD=changeme
16+
FUSEKI_LOCAL_USERNAME=admin
17+
FUSEKI_LOCAL_PASSWORD=changeme
1118

1219
# Google Sheets Configuration
1320
GOOGLE_SHEET_ID=1RL6Y120_H9-yD8x52eZO44S2iLQpLoZHitcExHsPfPs

.github/workflows/checks.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/docs.yaml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/pipeline.yaml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: Ontology CI/CD Pipeline
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # Manual trigger
7+
inputs:
8+
release_tag:
9+
description: 'Release tag to process (leave empty for latest)'
10+
required: false
11+
type: string
12+
13+
jobs:
14+
# ============================================
15+
# JOB 1: DOWNLOAD & VALIDATE
16+
# ============================================
17+
validate:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: 🧾 Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: 📥 Download ontology from release
24+
run: |
25+
# Get release info
26+
if [ -n "${{ inputs.release_tag }}" ]; then
27+
RELEASE_TAG="${{ inputs.release_tag }}"
28+
echo "Using specified release: ${RELEASE_TAG}"
29+
RELEASE_URL="https://api.github.com/repos/${{ github.repository }}/releases/tags/${RELEASE_TAG}"
30+
else
31+
echo "Using latest release"
32+
RELEASE_URL="https://api.github.com/repos/${{ github.repository }}/releases/latest"
33+
fi
34+
35+
# Get download URL for the ontology asset
36+
ASSET_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
37+
"${RELEASE_URL}" | \
38+
jq -r '.assets[] | select(.name=="AREMA-ontology.ttl") | .browser_download_url')
39+
40+
echo "📥 Downloading ontology from: ${ASSET_URL}"
41+
mkdir -p src/ontology
42+
curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
43+
"${ASSET_URL}" -o src/ontology/AREMA-ontology.ttl
44+
45+
echo "✅ Ontology downloaded"
46+
ls -lh src/ontology/AREMA-ontology.ttl
47+
48+
- name: 🐍 Set up Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: '3.12'
52+
53+
- name: 📦 Install uv
54+
run: |
55+
curl -LsSf https://astral.sh/uv/install.sh | sh
56+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
57+
58+
- name: 🔧 Sync Python environment
59+
run: uv sync --frozen
60+
61+
- name: ✅ SHACL Validation
62+
run: |
63+
echo "🔍 Validating ontology with SHACL shapes..."
64+
uv run python tools/python/checks/shacl.py \
65+
src/ontology/AREMA-ontology.ttl \
66+
src/quality-checks/skohub.shacl.ttl
67+
echo "✅ Validation passed!"
68+
69+
- name: 💾 Upload ontology artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: validated-ontology
73+
path: src/ontology/AREMA-ontology.ttl
74+
retention-days: 7
75+
76+
# ============================================
77+
# JOB 2: BUILD DOCS & DEPLOY
78+
# ============================================
79+
build-and-deploy:
80+
needs: validate
81+
runs-on: ubuntu-latest
82+
permissions:
83+
contents: write # Required to push docs back to repo
84+
85+
steps:
86+
- name: 🧾 Checkout repository
87+
uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0 # Full history for proper git operations
90+
91+
- name: 📥 Download validated ontology
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: validated-ontology
95+
path: src/ontology
96+
97+
- name: 📚 Build Documentation
98+
run: |
99+
echo "🏗️ Generating documentation with SKOHub..."
100+
101+
# Prepare environment
102+
mkdir -p docs
103+
echo "BASEURL=/" > .env
104+
echo "PATH_PREFIX=/" >> .env
105+
echo "GATSBY_BASE_PATH=/" >> .env
106+
107+
# Preserve CNAME if it exists
108+
[ -f docs/CNAME ] && cp docs/CNAME /tmp/CNAME || true
109+
110+
# Build using volumes (simpler than docker create/cp/start)
111+
docker run --rm \
112+
-v $(pwd)/src/ontology:/app/data \
113+
-v $(pwd)/.env:/app/.env \
114+
-v $(pwd)/tools/skohub-vocabs/config.yaml:/app/config.yaml \
115+
-v $(pwd)/tools/skohub-vocabs/src:/app/src/custom \
116+
-v $(pwd)/tools/skohub-vocabs/static:/app/static/custom \
117+
-v $(pwd)/docs:/app/public \
118+
ghcr.io/sdsc-ordes/skohub-vocabs:v0.3.2 \
119+
npm run build
120+
121+
# Restore CNAME
122+
[ -f /tmp/CNAME ] && mv /tmp/CNAME docs/CNAME || true
123+
124+
echo "✅ Documentation generated!"
125+
126+
- name: 💾 Commit Documentation & Ontology
127+
run: |
128+
git config user.name "github-actions[bot]"
129+
git config user.email "github-actions[bot]@users.noreply.github.com"
130+
131+
# Pull latest changes to avoid race conditions
132+
git pull --rebase origin ${{ github.ref_name }} || true
133+
134+
# Add both docs and the ontology file (updates src/ontology/)
135+
git add docs src/ontology/AREMA-ontology.ttl
136+
137+
# Only commit if there are changes
138+
if ! git diff --cached --quiet; then
139+
RELEASE_TAG="${{ github.event.release.tag_name || inputs.release_tag || 'manual' }}"
140+
git commit -m "Update ontology and docs from release ${RELEASE_TAG} [skip ci]"
141+
git push
142+
echo "✅ Documentation and ontology committed"
143+
else
144+
echo "ℹ️ No changes to commit"
145+
fi
146+
147+
- name: 🚀 Deploy to Fuseki
148+
env:
149+
FUSEKI_SPARQL_ENDPOINT: ${{ secrets.FUSEKI_SPARQL_ENDPOINT }}
150+
FUSEKI_USERNAME: ${{ secrets.FUSEKI_USERNAME }}
151+
FUSEKI_PASSWORD: ${{ secrets.FUSEKI_PASSWORD }}
152+
GRAPH_URI: ${{ secrets.GRAPH_URI }}
153+
run: |
154+
set -euo pipefail
155+
156+
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
157+
ARCHIVE_URI="${GRAPH_URI}/archive/${timestamp}"
158+
159+
echo "🚀 Deploying ontology to ${FUSEKI_SPARQL_ENDPOINT}"
160+
echo "📍 Target graph: ${GRAPH_URI}"
161+
echo "💾 Backup graph: ${ARCHIVE_URI}"
162+
163+
# Backup existing graph
164+
echo "📦 Backing up current graph..."
165+
curl -sf -u "${FUSEKI_USERNAME}:${FUSEKI_PASSWORD}" \
166+
-X POST \
167+
-H "Content-Type: application/sparql-update" \
168+
--data "COPY GRAPH <${GRAPH_URI}> TO GRAPH <${ARCHIVE_URI}>" \
169+
"${FUSEKI_SPARQL_ENDPOINT}" || echo "⚠️ No existing graph to back up"
170+
171+
# Drop existing graph
172+
echo "🧹 Dropping existing graph..."
173+
curl -sf -u "${FUSEKI_USERNAME}:${FUSEKI_PASSWORD}" \
174+
-X POST \
175+
-H "Content-Type: application/sparql-update" \
176+
--data "DROP GRAPH <${GRAPH_URI}>" \
177+
"${FUSEKI_SPARQL_ENDPOINT}"
178+
179+
# Upload new ontology
180+
echo "📤 Uploading ontology..."
181+
curl -sf -u "${FUSEKI_USERNAME}:${FUSEKI_PASSWORD}" \
182+
-X POST \
183+
-H "Content-Type: text/turtle" \
184+
--data-binary "@src/ontology/AREMA-ontology.ttl" \
185+
"${FUSEKI_SPARQL_ENDPOINT}?graph=${GRAPH_URI}"
186+
187+
echo "✅ Deployment completed successfully!"

.github/workflows/sync.yaml

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)