-
Notifications
You must be signed in to change notification settings - Fork 2
216 lines (180 loc) · 8.18 KB
/
Copy pathdeploy.yml
File metadata and controls
216 lines (180 loc) · 8.18 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Deploy MkDocs site to GitHub Pages
# Runs for:
# - pushes to main: build -> commit generated files -> deploy
# - PRs into main: build/validate only (no commits, no deploy)
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
# --------------------------------------------------------------------------------------
# Default shell behavior for ALL `run:` steps (both jobs)
#
# Why this:
# - GitHub's built-in `bash` already uses: `bash --noprofile --norc -eo pipefail {0}`
# which is effectively "fail fast" for bash scripts.
# - We add `-u` for extra safety: referencing unset variables becomes an error.
# - `--noprofile --norc` prevents unexpected user-profile side effects.
# - `pipefail` ensures a failing command inside a pipeline fails the step.
# --------------------------------------------------------------------------------------
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
# Prevent overlapping runs on the same ref from stepping on each other (e.g., deploy pushes).
# If you push multiple commits quickly, older runs for the same branch are canceled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Default least-privilege; PRs only need read
permissions:
contents: read
jobs:
build:
name: Build & validate (PRs and main)
runs-on: ubuntu-latest
steps:
# --- Checkout repo files so we can build & run scripts ---
- name: Checkout repository
uses: actions/checkout@v6
# --- Install Python with pip cache for faster subsequent runs ---
- name: Set up Python 3.x with pip cache
uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: pip
cache-dependency-path: scripts/requirements-deploy.txt
# --- Install all required Python packages for docs & tooling ---
- name: Install Python dependencies
run: pip install -r scripts/requirements-deploy.txt
# --- Clean up repo-specific detritus before generating docs ---
- name: Clean unwanted files
run: python scripts/clean-unwanted-files.py
# --- OWL post-processing (latest versioned pair): labels, synonyms, packages, stages, isDefinedBy, comment cleanup ---
- name: OWL post-processing (labels, packages, maturity)
run: python scripts/owl-postprocess.py
# --- Ensure ontology metadata is present/updated (gUFO file) ---
- name: Ensure metadata is added to gUFO file
run: python scripts/insert-metadata.py
# --- Promote newest versioned files into 'latest' folder ---
- name: Move newest files from versioned to latest
run: python scripts/move-latest.py
# --- Copy ontology changelog into docs so it appears on the MkDocs site ---
- name: Copy ontology changelog into docs
run: |
mkdir -p docs/deliverables
cp ontologies/changelog-ontology.md docs/deliverables/changelog-ontology.md
# --- Ensure no stale PyLODE HTML / docs remain (forces regeneration) ---
- name: Forces clean sync
run: |
rm -f docs/deliverables/specification-ontology.html
rm -f docs/method/specification-vocabulary.html
rm -f docs/deliverables/documentation.md
# --- Refresh images in docs from latest ontology assets ---
# Robust variant:
# - avoids glob failures when folders are empty or missing
# - ensures destination exists before copy
- name: Replace ontology images in docs with latest
run: |
rm -rf docs/deliverables/assets/images
mkdir -p docs/deliverables/assets/images
cp -r ontologies/latest/images/. docs/deliverables/assets/images/
# --- Generate OntoUML documentation (custom script) ---
- name: Generate OntoUML documentation
run: python scripts/docgen-ontouml.py
# --- Generate PyLODE HTML specs for ontology and vocabulary ---
- name: Generate PyLODE specifications
run: python scripts/docgen-pylode.py
# --- Convert SSSOM TSV to TTL (kept in repo + used in site) ---
- name: Create TTL serialization of SSSOM TSV
run: python scripts/sssom-tsv2ttl.py
# --- Include SSSOM TSV in built site (docs static assets) ---
- name: Copy SSSOM TSV into docs assets
run: |
mkdir -p docs/deliverables/assets
cp mappings/health-ri-mappings.tsv docs/deliverables/assets/health-ri-mappings.tsv
# --- Remove comments from public copy of TSV in docs assets ---
- name: Strip commented lines from public TSV copy
run: sed -i '/^#/d' docs/deliverables/assets/health-ri-mappings.tsv
# --- Validate MkDocs config before full build (fast fail) ---
- name: Validate MkDocs configuration
run: mkdocs build --verbose --clean --site-dir /tmp/mkdocs-check
# --- Build MkDocs site into ./site ---
- name: Build MkDocs site
run: mkdocs build
# --- Check internal links (ignore ephemeral hash-like URLs) ---
- name: Check links in built site
run: |
linkchecker ./site \
--no-status \
--ignore-url="n[0-9a-f]{32,}"
# --- Upload built site as artifact for deploy job ---
- name: Upload built site artifact
uses: actions/upload-artifact@v7
with:
name: site
path: site
retention-days: 7
# --- Upload generated content that should be committed on main ---
# This keeps the repo’s generated artifacts (ontologies, vocabulary, mappings, specs) up-to-date.
- name: Upload generated content artifact (to commit on main)
uses: actions/upload-artifact@v7
with:
name: generated
path: |
ontologies/versioned/**
ontologies/latest/**
vocabulary/versioned/**
vocabulary/latest/**
mappings/**
docs/deliverables/assets/health-ri-mappings.tsv
docs/deliverables/specification-ontology.html
docs/method/specification-vocabulary.html
retention-days: 7
deploy:
name: Commit generated files & publish (main only)
needs: build
runs-on: ubuntu-latest
# Only run on direct pushes to main (not PRs)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Needs write permission to commit and push changes
permissions:
contents: write
steps:
# --- Checkout the exact commit that triggered this workflow run ---
- name: Checkout repository
uses: actions/checkout@v6
# --- Retrieve generated files produced by the build job ---
- name: Download generated content artifact
uses: actions/download-artifact@v8
with:
name: generated
path: .
# --- Retrieve the already-built site folder ---
- name: Download built site artifact
uses: actions/download-artifact@v8
with:
name: site
path: ./site
# --- Commit any changes from generation (idempotent) ---
- name: Commit and push generated files (if there are changes)
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
shopt -s globstar
git add ontologies/versioned/** ontologies/latest/** || true
git add vocabulary/versioned/** vocabulary/latest/** || true
git add mappings/** || true
git add docs/deliverables/assets/health-ri-mappings.tsv || true
git add docs/deliverables/specification-ontology.html || true
git add docs/method/specification-vocabulary.html || true
# If nothing is staged, do nothing; otherwise commit + push.
git diff --cached --quiet || git commit -m "docs: update generated documentation and specifications"
# Future-proof: push back to the branch that triggered the run (here: main).
git push origin "HEAD:${GITHUB_REF_NAME}"
# --- Publish the built site to GitHub Pages from ./site ---
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site