Generic workflow - Export entities from footlight CMS to Artsdata #25
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: Export entities from footlight to Artsdata | |
on: | |
workflow_dispatch: | |
inputs: | |
onto-refine-config-url: | |
type: string | |
description: Onto Refine project configuration URL. This configuration is used to transform data. | |
required: true | |
footlight-url: | |
type: string | |
description: The entity URL that provides data in json format. | |
required: true | |
artifact-name: | |
type: string | |
description: The artifact name is used to identify the dataset in Nebula. | |
required: true | |
call-back-url: | |
type: string | |
description: The call back url. | |
required: true | |
jobs: | |
transform-open-api-events-using-ontorefine: | |
runs-on: ubuntu-latest | |
container: | |
image: ontotext/refine:1.2.1 | |
options: --user root | |
ports: | |
- 7333:7333 | |
outputs: | |
output_file_name: ${{ steps.step-5.outputs.file_name }} | |
steps: | |
- name: Install requirements | |
id: step-1 | |
run: apk update && apk add curl && apk add util-linux | |
- name: Run ontorefine server | |
id: step-2 | |
run: /opt/ontorefine/dist/bin/ontorefine & | |
- name: Download json data from the API | |
id: step-3 | |
run: | | |
curl '${{inputs.footlight-url}}' >> entities.json | |
- name: Download project-configuration-file | |
id: step-4 | |
run: | | |
curl '${{inputs.onto-refine-config-url}}' >> project-config.json | |
- name: Set output file name | |
id: step-5 | |
run: file_name="entities-$(uuidgen).ttl" && echo "file_name=$file_name" >> "$GITHUB_OUTPUT" | |
- name: Transform json data to RDF | |
id: step-6 | |
run: | | |
/opt/ontorefine/dist/bin/ontorefine-cli \ | |
transform entities.json \ | |
-u http://localhost:7333 \ | |
--configurations project-config.json \ | |
-f json > "$file_name" | |
- name: Upload RDF file to S3 | |
id: step-8 | |
uses: keithweaver/[email protected] | |
with: | |
command: cp | |
source: $file_name | |
destination: s3://footlight-aggregator-pipeline-files | |
aws_access_key_id: ${{ secrets.S3_ACCESS_KEY_ID}} | |
aws_secret_access_key: ${{ secrets.S3_SECRET_ACCESS_KEY }} | |
aws_region: ca-central-1 | |
flags: --acl public-read --content-type text/turtle | |
upload-to-artsdata: | |
needs: transform-open-api-events-using-ontorefine | |
runs-on: ubuntu-latest | |
steps: | |
- env: | |
FILE_NAME: ${{needs.transform-open-api-events-using-ontorefine.outputs.output_file_name}} | |
run: | | |
echo "File name : $FILE_NAME" | |
- name: Set current date as output | |
id: version # this is used on variable path | |
run: echo "dumpdate=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_OUTPUT | |
- name: Call Artsdata Databus | |
run: | | |
curl \ | |
-H 'Content-Type: application/json' \ | |
-X POST http://api.artsdata.ca/databus/ \ | |
--data '{ "artifact": "${{inputs.artifact-name}}", | |
"comment": "Entites from the Footlight: ${{inputs.footlight-url}}", | |
"publisher": "${{ secrets.PUBLISHER_URI_GREGORY }}", | |
"group": "${{ github.event.repository.name }}", | |
"version": "${{ steps.version.outputs.dumpdate }}", | |
"downloadUrl": "https://footlight-aggregator-pipeline-files.s3.ca-central-1.amazonaws.com/$FILE_NAME", | |
"downloadFile": "$FILE_NAME", | |
"reportCallbackUrl": "${{inputs.call-back-url}}" | |
}' |