Skip to content

added catalog to components, completely removed logistics #2

added catalog to components, completely removed logistics

added catalog to components, completely removed logistics #2

Workflow file for this run

# ==============================================================================
# WORKFLOW: Update Repo Config
# ==============================================================================
# Purpose: Synchronizes the repository structure with ODK configuration changes
#
# This workflow:
# 1. Detects changes to ODK configuration files (*-odk.yaml or project-odk.yaml)
# 2. Runs `odk.py update` to regenerate the Makefile and sync repository structure
# 3. Commits the updated files back to the repository
# 4. Triggers the Build/QC workflow to rebuild release artifacts with the new config
#
# What `odk.py update` (make update_repo) does:
# - Regenerates the ODK Makefile based on the YAML configuration
# - Synchronizes SPARQL query templates
# - Updates release artifact configurations
# - Regenerates documentation templates
# - Adds/removes component and import targets as needed
#
# Execution Chain Position:
# update-repo → [BUILD/QC] → docs
#
# This workflow does NOT run standalone — it feeds into the main build chain.
#
# Read more about ODK update_repo:
# https://github.com/INCATools/ontology-development-kit#update_repo
# ==============================================================================
name: Update Repo Config
# ==============================================================================
# WORKFLOW TRIGGERS
# ==============================================================================
# This workflow runs whenever ODK configuration files are modified.
# It then triggers the QC build to rebuild release artifacts using the
# updated configuration.
# ==============================================================================
on:
# ============================================================================
# TRIGGER 1: Push Events (for configuration changes)
# ============================================================================
# Triggers when ODK configuration files are modified and pushed to main.
#
# Monitored files:
# - src/ontology/*-odk.yaml : Ontology-specific internal ODK configuration
# (generated by ODK seed; contains the full resolved config)
# Adding this path ensures that root-level config edits also trigger the
# update — a common source of confusion when this was missing.
#
# Typical configuration changes that trigger this workflow:
# - Adding or removing component products
# - Changing import configurations (new imports, changed URLs)
# - Modifying release settings (products, formats)
# - Updating ontology metadata (title, description, version format)
# ============================================================================
push:
branches: ["main"]
paths:
- 'src/ontology/*-odk.yaml' # Internal ODK config (inside ontology dir)
# ============================================================================
# TRIGGER 2: Pull Request Events (for PR validation before merge)
# ============================================================================
# Validates that configuration updates run `odk.py update` cleanly before
# the PR is merged to main. Commits are skipped for PRs (see commit step).
# ============================================================================
pull_request:
branches: ["main"]
paths:
- 'src/ontology/*-odk.yaml'
# ============================================================================
# TRIGGER 3: Manual Trigger (for forced updates)
# ============================================================================
# Allows manual execution via GitHub UI or API.
# Useful for:
# - Forcing repository synchronization without changing config files
# - Testing configuration update behavior
# - Recovering from a desynchronized Makefile state
# ============================================================================
workflow_dispatch:
# ============================================================================
# TRIGGER 4: Repository Dispatch (for workflow integration)
# ============================================================================
# Can be triggered by other workflows that need to force a config update.
# Not used in the default setup-repo chain, but available for custom
# integration scenarios where config must be regenerated programmatically.
# ============================================================================
repository_dispatch:
types: [trigger-update-repo]
# ==============================================================================
# ENVIRONMENT VARIABLES
# ==============================================================================
env:
# Default branch for git operations
DEFAULT_BRANCH: main
# ==============================================================================
# JOBS
# ==============================================================================
jobs:
# ============================================================================
# JOB 1: check-ontology-dir
# ============================================================================
# Pre-flight check: verifies that src/ontology/ exists before attempting
# the update. This prevents workflow failures in new or empty repositories
# where the directory hasn't been created yet (e.g. before setup-repo runs).
#
# Output:
# - dir-exists: "true" | "false" — consumed by the update-config job
# ============================================================================
check-ontology-dir:
runs-on: ubuntu-latest
outputs:
dir-exists: ${{ steps.check.outputs.exists }}
steps:
# ========================================================================
# STEP 1.1: Checkout Repository
# ========================================================================
# Lightweight checkout (no full history needed — only checking directory)
# ========================================================================
- name: Checkout repository
uses: actions/checkout@v4
# ========================================================================
# STEP 1.2: Check for Ontology Directory
# ========================================================================
# Sets output flag for the dependent job to consume.
# If src/ontology/ doesn't exist, the entire workflow is gracefully skipped.
# ========================================================================
- name: Check for ontology directory
id: check
run: |
if [ -d "src/ontology" ]; then
echo "Ontology directory found: src/ontology/"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "No src/ontology/ directory found — skipping workflow."
echo "Run the Setup New Ontology workflow first."
echo "exists=false" >> $GITHUB_OUTPUT
fi
# ============================================================================
# JOB 2: update-config
# ============================================================================
# Main job: runs `odk.py update` inside the ODK container to regenerate
# the repository structure based on the current ODK configuration.
#
# Dependencies: requires check-ontology-dir to complete first
# Condition: only runs if src/ontology/ exists
# Container: odkfull:v1.6 (provides odk.py, make, ROBOT, etc.)
# ============================================================================
update-config:
runs-on: ubuntu-latest
# Grant write permission for committing regenerated files
permissions:
contents: write
needs: check-ontology-dir
# Only run if the ontology directory exists
if: needs.check-ontology-dir.outputs.dir-exists == 'true'
# Use the full ODK container for consistent tooling
# Version pinned for reproducibility
container: obolibrary/odkfull:v1.6
steps:
# ========================================================================
# STEP 2.1: Checkout Repository
# ========================================================================
# Full history fetch for accurate ODK operations and git versioning.
# ========================================================================
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for ODK make targets
# ========================================================================
# STEP 2.2: Configure Git Identity
# ========================================================================
# Sets the git user identity for automated commits.
# safe.directory is required inside Docker containers (git security check).
# ========================================================================
- name: Configure git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Required when git runs inside Docker (UID mismatch protection)
git config --global --add safe.directory $GITHUB_WORKSPACE
# ========================================================================
# STEP 2.3: Run ODK Update Repo
# ========================================================================
# Synchronizes the repository structure with the current ODK configuration.
#
# Command: `odk.py update`
# - Must be run from src/ontology/ where the {id}-odk.yaml config resides
# - Reads the ODK YAML config and regenerates the Makefile + config files
# - Equivalent to `make update_repo` but using the ODK Python CLI directly
# - No need to manually detect/copy the config file (odk.py finds it automatically)
#
# What gets updated:
# - src/ontology/Makefile (ODK build targets)
# - SPARQL query templates
# - Release artifact configurations
# - Documentation templates
# - Component and import build targets
# ========================================================================
- name: Run ODK update repo
working-directory: src/ontology
run: |
echo "Running odk.py update to sync repository structure..."
odk.py update
echo "Repository configuration update complete."
# ========================================================================
# STEP 2.4: Commit Updated Configuration Files
# ========================================================================
# Commits all files modified by `odk.py update` back to the repository.
#
# Conditions:
# - SKIPPED for pull requests: PR contributors review changes manually
# - Skipped automatically if there are no changes (EndBug/add-and-commit@v9
# detects empty commits and skips them gracefully)
#
# Scope: commits the entire src/ directory to capture all regenerated files.
# This is intentional — update_repo may modify multiple config files in
# different subdirectories, and committing src/ ensures nothing is missed.
# ========================================================================
- name: Commit updated configuration files
# Only commit on non-PR events
if: github.event_name != 'pull_request'
uses: EndBug/add-and-commit@v9
with:
message: "ODK: Update repository configuration (make update_repo)"
# Add all files in src/ — captures all files modified by odk.py update
add: "src"
cwd: "."
default_author: github_actions
push: true
# ========================================================================
# STEP 2.5: Trigger QC Build Workflow
# ========================================================================
# After regenerating the repository structure, dispatch a repository event
# to kick off the Build/QC workflow (qc.yml). This ensures the updated
# Makefile is immediately used to rebuild all release artifacts.
#
# Workflow chain:
# [this: update-repo] → trigger-qc → qc.yml → trigger-docs → docs.yml
#
# Condition: Only dispatch for non-PR events.
# - PR builds don't deploy or trigger downstream workflows
# - The QC build runs automatically after the PR merges to main
# ========================================================================
- name: Trigger QC build workflow
if: github.event_name != 'pull_request'
uses: peter-evans/repository-dispatch@v3
with:
# GITHUB_TOKEN available with 'contents: write' permission on this job
token: ${{ secrets.GITHUB_TOKEN }}
# qc.yml listens for this event type via its repository_dispatch trigger
event-type: trigger-qc
# ==============================================================================
# WORKFLOW NOTES
# ==============================================================================
# This workflow now participates in the main build chain:
# update-repo → qc (BUILD) → docs
#
# Typical scenarios that trigger this workflow:
# 1. You add a new component in *-odk.yaml → update_repo adds its build target
# 2. You add a new import → update_repo updates import processing config
# 3. You change release settings → update_repo updates artifact configurations
# 4. You update metadata → update_repo regenerates documentation templates
#
# After this workflow completes, the QC build runs automatically to produce
# updated release artifacts reflecting the new configuration.
# ==============================================================================