-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (71 loc) · 2.7 KB
/
ontology-check-trigger.yml
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
name: Check Ontology Release & Trigger Build-Deploy
on:
workflow_call:
inputs:
ontology:
description: 'The ontology to use.'
required: true
type: string
international:
description: 'Is the ontology babelon international?'
default: false
type: boolean
load:
description: 'Should load the data?'
default: true
type: boolean
jobs:
watcher:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.sha.outputs.value }}
deploy: ${{ steps.compare.outputs.value }}
international: ${{steps.international.outputs.value}}
steps:
- name: Authenticate to Google Cloud
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCLOUD_SA_KEY }}'
- name: Setup Google Cloud CLI
uses: 'google-github-actions/setup-gcloud@v2'
- name: Install jq
run: sudo apt-get install jq
- name: Get ontology config json
run: |
wget https://raw.githubusercontent.com/TheJacksonLaboratory/ontology-service/main/config/ontologies.json
- name: Subset ontology config json
run: jq -r '.[] | select(.prefix=="${{ inputs.ontology }}")' ontologies.json > target.json
- name: Get international config
uses: sergeysova/jq-action@v2
id: international
with:
cmd: "jq -r '.international' target.json"
- name: Get purl for ontology file
uses: sergeysova/jq-action@v2
id: purl
with:
cmd: "jq -r '.base_file' target.json"
- name: Generate sha1 from purl file
id: sha
run: |
SHA=$(curl -L ${{ steps.purl.outputs.value }} | shasum | cut -c -7)
echo "value=$SHA" >> $GITHUB_OUTPUT
- name: Get existing sha from service
id: existing
run: |
EXISTING=$(gcloud container images list-tags us-docker.pkg.dev/jax-cs-registry/docker/ontology/ontology-service-${{ inputs.ontology }} --limit 1 2>/dev/null | tail -n 1 | awk '{print $2}' | tr ',' '\n' | grep -v "latest" | grep -v "\." || echo "")
echo "value=$EXISTING" >> $GITHUB_OUTPUT
- name: Compare sha for load
id: compare
run: |
echo "value=${{steps.sha.outputs.value != steps.existing.outputs.value }}" >> "$GITHUB_OUTPUT"
trigger_deploy:
needs: watcher
if: needs.watcher.outputs.deploy == 'true'
uses: TheJacksonLaboratory/ontology-service/.github/workflows/ontology-build-deploy.yml@main
with:
ontology: ${{ inputs.ontology }}
international: ${{fromJSON(needs.watcher.outputs.international)}}
load: ${{ inputs.load }}
tag: ${{needs.watcher.outputs.sha}}
secrets: inherit