Skip to content

Import Google Sheet to Artsdata #59

Import Google Sheet to Artsdata

Import Google Sheet to Artsdata #59

name: Import Google Sheet to Artsdata
on:
workflow_dispatch:
inputs:
spreadsheet_url:
description: 'Google Spreadsheet /export?exportFormat=csv'
type: string
required: true
default: 'https://docs.google.com/spreadsheets/d/1fPcWbdSL-gcLmeGWVCID9TjBq5fGk4vG4HG2E7kSAb0/export?exportFormat=csv'
artifact:
description: 'Artifact'
type: string
required: true
default: 'test-events'
prefix:
description: 'Prefix'
type: string
required: true
default: 'http://test-events/'
publisher:
description: 'Publisher ID'
type: string
required: true
jobs:
download-and-transform-data:
runs-on: ubuntu-latest
outputs:
output-file-path: ${{ steps.step-5.outputs.events_file_name }}
container:
image: ontotext/refine:1.2.0
options: --user root
ports:
- 7333:7333
steps:
- name: Install requirements
id: step-1
run: apk update && apk add curl && apk add util-linux
- name: Run Onto Refine server
id: step-2
run: /opt/ontorefine/dist/bin/ontorefine &
- name: Download data from Google Sheet
id: step-3
run: |
curl -L ${{inputs.spreadsheet_url}} -o events.csv
- name: Download configuration files for transformation
id: step-4
run: |
curl 'https://raw.githubusercontent.com/culturecreates/artsdata-google-workspace-smart-chip/main/ontorefine/sheet-configuration.json' >> event-transform-config.json
- name: Set prefix in RDF mapping
id: step-4-set-sheet-prefix
run: |
sed -i "s|http://google-sheet/|${{inputs.prefix}}|g" event-transform-config.json
- name: Set output file name
id: step-5
run: |
echo "events_file_name=events-$(uuidgen).ttl" >> $GITHUB_OUTPUT
- name: List files
id: step-6-info
run: |
ls -la
- name: Transform events in CSV to RDF
id: step-6
run: |
/opt/ontorefine/dist/bin/ontorefine-cli \
transform events.csv \
-u http://localhost:7333 \
--configurations event-transform-config.json \
-f csv >> ${{steps.step-5.outputs.events_file_name}}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: events
path: ./${{steps.step-5.outputs.events_file_name}}
retention-days: 1
commit-to-github:
runs-on: ubuntu-latest
needs: download-and-transform-data
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
id: download-step
uses: actions/download-artifact@v4
with:
name: events
path: ./events
- name: Copy files
run: |
mkdir -p outputs
cp /home/runner/work/artsdata-google-workspace-smart-chip/artsdata-google-workspace-smart-chip/events/${{needs.download-and-transform-data.outputs.output-file-path}} ./outputs/${{needs.download-and-transform-data.outputs.output-file-path}}
- name: Commit file to GitHub
run: |
git pull
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add "outputs/${{needs.download-and-transform-data.outputs.output-file-path}}"
git commit -m "Push Event TTL file"
git push
artsdata-push:
runs-on: ubuntu-latest
needs: [commit-to-github, download-and-transform-data]
steps:
- name: Action setup
uses: culturecreates/[email protected]
with:
artifact: ${{inputs.artifact}}
group: google-sheet
publisher: "${{inputs.publisher}}"
downloadUrl: https://raw.githubusercontent.com/culturecreates/artsdata-google-workspace-smart-chip/main/outputs/${{needs.download-and-transform-data.outputs.output-file-path}}