Update build.yml #214
This file contains 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 | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- 'config/*' | |
push: | |
paths: | |
- 'config.yaml' | |
- '.github/workflows/build.yml' | |
- './config/*' | |
schedule: | |
- cron: 1 0 1 1-12 * | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install yq | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq | |
sudo chmod +x /usr/bin/yq | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
- name: Add slimmer and robot URLs to environment | |
run: | | |
config_file="config.yaml" | |
robot_jar=$(yq '.robot."robot-jar"' $config_file) | |
robot_wrapper=$(yq '.robot."robot-wrapper"' $config_file) | |
slimmer=$(yq '.slimmer' $config_file) | |
echo "slimmer=$slimmer" >> $GITHUB_ENV | |
echo "robot=$robot_wrapper" >> $GITHUB_ENV | |
echo "robot_jar=$robot_jar" >> $GITHUB_ENV | |
- name: Get slimmer and robot | |
run: | | |
wget ${{ env.slimmer }} | |
wget ${{ env.robot }} | |
wget ${{ env.robot_jar }} | |
- name: Authorize running slim scripts | |
run: chmod 755 src/build-workflow/*.sh | |
slim: | |
needs: setup | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
ontology: [aopo, bao, bfo, bto, ccont, cheminf, chebi, chmo, clo, efo, envo, fabio, go, iao, ncit, npo, oae, obcs, obi, pato, ro, sio, uberon, uo, msio] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Run slim script for ${{ matrix.ontology }} | |
run: bash src/build-workflow/slim.sh ${{ matrix.ontology }} | |
- name: Check if file has changed | |
id: file_changed | |
run: | | |
file="external-dev/${{ matrix.ontology }}-ext.owl" | |
if git diff --quiet HEAD -- $file; then | |
echo "changed=false" >> $GITHUB_ENV | |
else | |
echo "changed=true" >> $GITHUB_ENV | |
fi | |
- name: Upload slim artifact if changed | |
if: env.changed == 'true' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.ontology }}-ext.owl | |
path: external-dev/${{ matrix.ontology }}-ext.owl | |
commit: | |
needs: slim | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Create temporary directory for artifacts | |
run: mkdir -p temp-artifacts | |
- name: Download all slim artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: temp-artifacts | |
- name: Move downloaded artifacts to external-dev | |
run: | | |
ls temp-artifacts | |
for file in temp-artifacts/*-ext.owl; do | |
mv "$file" external-dev/ | |
echo "Moved: $file" | |
done | |
rm temp-artifacts/* | |
- name: Commit changed OWL files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Slimmer bot" | |
git add -f external-dev/*.owl | |
git commit -m "Actions - slim updated" || echo "No changes to commit." | |
git push || echo "Push failed." |