Build slims #281
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build slims (Matrix) | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - 'config.yaml' | |
| - '.github/workflows/build.yml' | |
| - './config/*' | |
| - './internal*' | |
| - './external*' | |
| - './scripts/build-workflow/*' | |
| push: | |
| paths: | |
| - 'config.yaml' | |
| - '.github/workflows/build.yml' | |
| - './config/*' | |
| - './internal*' | |
| - './external*' | |
| - './scripts/build-workflow/*' | |
| schedule: | |
| - cron: 1 0 1 1-12 * | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| slimmer: ${{ steps.config.outputs.slimmer }} | |
| robot: ${{ steps.config.outputs.robot }} | |
| robot_jar: ${{ steps.config.outputs.robot_jar }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| - name: Convert slimmer config to ROBOT term files | |
| run: bash scripts/build-workflow/slimmer2robot.sh | |
| - name: Extract config values | |
| id: config | |
| run: | | |
| echo $(java --version) | |
| config_file="config.yaml" | |
| robot_jar="" | |
| robot="" | |
| slimmer="" | |
| while IFS=":" read -r key value; do | |
| key=$(echo "$key" | tr -d '[:space:]') | |
| case "$key" in | |
| robot-jar) | |
| robot_jar=$(echo "$value" | tr -d '[:space:]') | |
| ;; | |
| robot-wrapper) | |
| robot=$(echo "$value" | tr -d '[:space:]') | |
| ;; | |
| slimmer) | |
| slimmer=$(echo "$value" | tr -d '[:space:]') | |
| ;; | |
| esac | |
| done < "$config_file" | |
| echo SLIMMER: $slimmer | |
| echo ROBOT JAR: $robot_jar | |
| echo ROBOT WRAPPER: $robot | |
| echo "slimmer=${slimmer}" >> $GITHUB_OUTPUT | |
| echo "robot=${robot}" >> $GITHUB_OUTPUT | |
| echo "robot_jar=${robot_jar}" >> $GITHUB_OUTPUT | |
| - name: Authorize running build scripts | |
| run: chmod 755 scripts/build-workflow/*.sh | |
| build: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ontology: [aopo, bao, bfo, bto, ccont, cheminf, chebi, chmo, clo, efo, envo, fabio, go, iao, ncit, npo, oae, obcs, obi, pato, sio, uberon, uo, msio] | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| - name: get slimmer | |
| run: wget ${{ needs.setup.outputs.slimmer }} | |
| - name: get robot | |
| run: | | |
| wget ${{ needs.setup.outputs.robot }} | |
| wget ${{ needs.setup.outputs.robot_jar }} | |
| - name: build-${{ matrix.ontology }} | |
| run: | | |
| rm external-dev/${{ matrix.ontology }}-slim.owl | |
| bash scripts/build-workflow/build.sh ${{ matrix.ontology }} | |
| - name: Upload built ontology | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.ontology }}-owl | |
| path: external-dev/${{ matrix.ontology }}-slim.owl | |
| retention-days: 1 | |
| commit: | |
| needs: [setup, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| - name: Download all built ontologies | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Move artifacts to external-dev | |
| run: | | |
| mkdir -p external-dev | |
| find artifacts -name "*-slim.owl" -exec cp {} external-dev/ \; | |
| - name: Commit OWL files | |
| run: | | |
| if [[ "${{ github.ref_name }}" == *"merge"* ]]; then | |
| exit 0 | |
| fi | |
| git checkout "${{ github.ref_name }}" | |
| git pull | |
| git add -f external-dev/*-slim.owl | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "Slimmer bot" | |
| # Check if there are changes to commit | |
| if git diff-index --quiet HEAD --; then | |
| echo "No changes to commit." | |
| else | |
| git commit -m "Actions - build updated" ./external-dev/*-slim.owl || true | |
| fi | |
| # Check if there are changes to push | |
| if [[ $(git rev-parse --abbrev-ref HEAD) == "${{ github.ref_name }}" ]]; then | |
| if [ -n "$(git cherry -v)" ]; then | |
| git push || echo "Push failed." | |
| else | |
| echo "No changes to push." | |
| fi | |
| fi |