1+ # SEEDING ODK workflow
2+
3+ name : seed odk
4+
5+ # Controls when the action will run.
6+ on :
7+ # Allows you to run this workflow manually from the Actions tab
8+ workflow_dispatch :
9+ inputs :
10+ ontology_id :
11+ description : ' Ontology ID (replaces id in seed.yaml)'
12+ required : true
13+ uribase_suffix :
14+ description : ' URI base suffix (replaces uribase_suffix in seed.yaml)'
15+ required : true
16+ odk_tag :
17+ description : ' ODK Docker tag to use'
18+ required : false
19+ default : ' latest'
20+ config_file :
21+ description : ' Configuration file name'
22+ required : false
23+ default : ' seed-template.yaml'
24+
25+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
26+ jobs :
27+ # This workflow contains a single job called "seed_ontology"
28+ seed_ontology :
29+ # The type of runner that the job will run on
30+ runs-on : ubuntu-latest
31+ container : obolibrary/odkfull:${{ github.event.inputs.odk_tag || 'latest' }}
32+
33+ # Steps represent a sequence of tasks that will be executed as part of the job
34+ steps :
35+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
36+ - uses : actions/checkout@v4
37+
38+ - name : Set up Git config
39+ run : |
40+ git config --global user.name "${{ github.actor }}"
41+ git config --global user.email "${{ github.actor }}@users.noreply.github.com"
42+
43+ - name : Generate unique branch name
44+ run : |
45+ BRANCH_NAME="fresh-seed-$(date +%Y%m%d-%H%M%S)"
46+ echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
47+
48+ - name : Verify seed config file exists
49+ run : |
50+ if [ ! -f "${{ github.event.inputs.config_file || 'seed-template.yaml' }}" ]; then
51+ echo "Error: Configuration file ${{ github.event.inputs.config_file || 'seed-template.yaml' }} not found!"
52+ exit 1
53+ fi
54+ echo "Using configuration file: ${{ github.event.inputs.config_file || 'seed-template.yaml' }}"
55+
56+ - name : Update seed-template.yaml with input values
57+ run : |
58+ CONFIG_FILE="${{ github.event.inputs.config_file || 'seed-template.yaml' }}"
59+
60+ echo "Original seed-template.yaml content:"
61+ cat "$CONFIG_FILE"
62+
63+ # Replace id value
64+ sed -i "s/^id:.*/id: ${{ github.event.inputs.ontology_id }}/" "$CONFIG_FILE"
65+
66+ # Replace uribase_suffix value
67+ sed -i "s/^uribase_suffix:.*/uribase_suffix: ${{ github.event.inputs.uribase_suffix }}/" "$CONFIG_FILE"
68+
69+ echo "Updated seed-template.yaml content:"
70+ cat "$CONFIG_FILE"
71+
72+ - name : Run ODK seed
73+ env :
74+ ODK_IMAGE : odkfull
75+ ODK_TAG : ${{ github.event.inputs.odk_tag || 'latest' }}
76+ ODK_GITNAME : ${{ github.actor }}
77+ ODK_GITEMAIL : ${{ github.actor }}@users.noreply.github.com
78+ run : |
79+ echo "This script only works with ODK 1.3.2 and later. For ODK 1.3.1 or earlier, use https://raw.githubusercontent.com/INCATools/ontology-development-kit/v1.3.1/seed-via-docker.sh"
80+ /tools/odk.py seed \
81+ --gitname "$ODK_GITNAME" \
82+ --gitemail "$ODK_GITEMAIL" \
83+ -c \
84+ -C ${{ github.event.inputs.config_file || 'seed-template.yaml' }}
85+
86+ - name : Copy generated files to root
87+ run : |
88+ TARGET_DIR="target/${{ github.event.inputs.ontology_id }}"
89+ if [ ! -d "$TARGET_DIR" ]; then
90+ echo "Error: Target directory $TARGET_DIR not found!"
91+ exit 1
92+ fi
93+
94+ echo "Copying files from $TARGET_DIR to root, excluding .git and .github directories..."
95+
96+ # Copy all files and directories except .git and .github
97+ find "$TARGET_DIR" -mindepth 1 -maxdepth 1 ! -name '.git' ! -name '.github' -exec cp -r {} . \;
98+
99+ # List what was copied
100+ echo "Files copied to root:"
101+ ls -la
102+
103+ - name : Clean up target directory
104+ run : |
105+ echo "Removing target directory to avoid git conflicts..."
106+ rm -rf target/
107+ git status
108+
109+ - name : Create Pull Request
110+ uses : peter-evans/create-pull-request@v5
111+ with :
112+ branch : ${{ env.BRANCH_NAME }}
113+ base : main
114+ title : " ODK Seed: ${{ github.event.inputs.ontology_id }}"
115+ commit-message : " ODK seed generated files for ${{ github.event.inputs.ontology_id }} using ${{ github.event.inputs.config_file || 'seed.yaml' }}"
116+ body : |
117+ ## ODK Seed Generated Files
118+
119+ - **Ontology ID**: `${{ github.event.inputs.ontology_id }}`
120+ - **URI Base Suffix**: `${{ github.event.inputs.uribase_suffix }}`
121+ - **Config File**: `${{ github.event.inputs.config_file || 'seed-template.yaml' }}`
122+ - **ODK Tag**: `${{ github.event.inputs.odk_tag || 'latest' }}`
123+
124+ This PR contains the generated ontology files from ODK seed.
0 commit comments