-
Notifications
You must be signed in to change notification settings - Fork 2
111 lines (91 loc) · 3.94 KB
/
pipeline.yaml
File metadata and controls
111 lines (91 loc) · 3.94 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Ontology CI/CD Pipeline
on:
release:
types: [published]
workflow_dispatch: # Manual trigger
inputs:
release_tag:
description: 'Release tag to process (leave empty for latest)'
required: false
type: string
jobs:
# ============================================
# VALIDATE, BUILD & DEPLOY
# ============================================
validate-build-deploy:
runs-on: ubuntu-latest
permissions:
contents: write # Required to push docs back to repo
steps:
- name: 🧾 Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0 # Full history for proper git operations
- name: 📥 Download ontology from release
run: |
# Get release info
if [ -n "${{ inputs.release_tag }}" ]; then
RELEASE_TAG="${{ inputs.release_tag }}"
echo "Using specified release: ${RELEASE_TAG}"
RELEASE_URL="https://api.github.com/repos/${{ github.repository }}/releases/tags/${RELEASE_TAG}"
else
echo "Using latest release"
RELEASE_URL="https://api.github.com/repos/${{ github.repository }}/releases/latest"
fi
# Get download URL for the ontology asset
ASSET_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"${RELEASE_URL}" | \
jq -r '.assets[] | select(.name=="AREMA-ontology.ttl") | .browser_download_url')
echo "📥 Downloading ontology from: ${ASSET_URL}"
mkdir -p src/ontology
curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"${ASSET_URL}" -o src/ontology/AREMA-ontology.ttl
echo "✅ Ontology downloaded"
ls -lh src/ontology/AREMA-ontology.ttl
- name: Build Documentation
run: |
echo "🏗️ Generating documentation with SKOHub..."
# Prepare environment
mkdir -p docs
echo "BASEURL=/" > .env
echo "PATH_PREFIX=/" >> .env
echo "GATSBY_BASE_PATH=/" >> .env
# Preserve CNAME if it exists
[ -f docs/CNAME ] && cp docs/CNAME /tmp/CNAME || true
# Clear docs folder
rm -rf docs/*
# Create container with volume mounts for input only
CONTAINER_ID=$(docker create \
-v $(pwd)/src/ontology:/app/data \
-v $(pwd)/.env:/app/.env \
-v $(pwd)/tools/skohub-vocabs/config.yaml:/app/config.yaml \
-v $(pwd)/tools/skohub-vocabs/src:/app/src/custom \
-v $(pwd)/tools/skohub-vocabs/static/img:/app/static/img \
ghcr.io/sdsc-ordes/skohub-vocabs:v0.4.0 \
npm run build
)
# Run build
docker start -a $CONTAINER_ID
# Copy output from container
docker cp $CONTAINER_ID:/app/public/. ./docs/
# Cleanup
docker rm $CONTAINER_ID
# Restore CNAME
[ -f /tmp/CNAME ] && mv /tmp/CNAME docs/CNAME || true
echo "✅ Documentation generated!"
- name: 💾 Commit Documentation
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Add only docs (not the ontology file)
git add docs
# Only commit if there are changes
if ! git diff --cached --quiet; then
RELEASE_TAG="${{ github.event.release.tag_name || inputs.release_tag || 'manual' }}"
git commit -m "docs: update docs from release ${RELEASE_TAG} [skip ci]"
git push origin ${{ github.event.repository.default_branch }}
echo "✅ Documentation committed"
else
echo "ℹ️ No changes to commit"
fi