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: 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 }} | ||
steps:g | ||
- name: Authenticate to Google Cloud | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GCLOUD_SA_KEY }}' | ||
- name: Setup Google Cloud CLI | ||
uses: 'google-github-actions/setup-gcloud@v1' | ||
- name: Get ontology config | ||
run: | | ||
wget https://raw.githubusercontent.com/TheJacksonLaboratory/ontology-service/main/config/ontologies.json | ||
- name: Get json by ontology | ||
uses: sergeysova/jq-action@v2 | ||
id: target | ||
with: | ||
cmd: "jq -r '.[] | select(.prefix==\"${{ inputs.ontology }}\")' ontologies.json > target.json" | ||
- name: Get latest tag_name | ||
uses: sergeysova/jq-action@v2 | ||
id: purl | ||
with: | ||
cmd: "jq -r '.[] | select(.prefix==\"${{ inputs.ontology}}\").base_file' target.json" | ||
- name: Get latest SHA | ||
uses: sergeysova/jq-action@v2 | ||
id: sha | ||
with: | ||
cmd: "curl \"${{ steps.purl.outputs.value }}\" | shasum | cut -c -7" | ||
- name: Get existing SHA for 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 and configure | ||
id: compare | ||
run: | | ||
echo "value=${{steps.sha.outputs.value != steps.existing.outputs.value }}" >> "$GITHUB_OUTPUT" | ||
echo "${{steps.sha.outputs.value != steps.existing.outputs.value }}" | ||
- name: Get international config | ||
uses: sergeysova/jq-action@v2 | ||
id: international | ||
with: | ||
cmd: "jq -r '.international'' target.json" | ||
- name: Check values | ||
run: | ||
echo "${{steps.international.outputs.value}}" | ||
echo "${{steps.purl.outputs.value}}" | ||
# 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: ${{ inputs.international }} | ||
# load: ${{ inputs.load }} | ||
# tag: "${{needs.watcher.outputs.sha}}" | ||
# secrets: inherit |