Skip to content

Commit

Permalink
Added new workflows to get CMS data
Browse files Browse the repository at this point in the history
  • Loading branch information
sahalali committed Nov 25, 2024
1 parent 92180d3 commit dfc91dc
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/export-cms-entitiesv2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Export Footlight-CMS entities to Artsdata v2

on:
workflow_call:
inputs:
calendar_id:
required: true
type: string
login_email:
required: true
type: string
secrets:
PUBLISHER_URI_GREGORY:
required: true
S3_ACCESS_KEY_ID:
required: true
S3_SECRET_ACCESS_KEY:
required: true
LOGIN_PASSWORD:
required: true


jobs:
get-rdf-data:
runs-on: ubuntu-latest
outputs:
calendar-slug: ${{ steps.get-calendar-slug.outputs.CALENDAR_SLUG }}
steps:
- name: Login to CMS
id: login-step
run: |
response=$(curl -s -X 'POST' \
'https://api.cms.footlight.io/login' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-H 'Referer: https://api.cms.footlight.io/export' \
-d '{
"email": "'"${{inputs.login_email}}"'",
"password": "'"${{secrets.LOGIN_PASSWORD}}"'"
}')
token=$(echo $response | jq -r '.accessToken')
echo "::add-mask::$token" # Mask the token
echo "ACCESS_TOKEN=$token" >> $GITHUB_OUTPUT
- name: Get calendar slug
id: get-calendar-slug
run: |
response=$(curl -X 'GET' \
"https://api.cms.footlight.io/calendars/${{inputs.calendar_id}}" \
-H "accept: */*" \
-H "Authorization: Bearer ${{steps.login-step.outputs.ACCESS_TOKEN}}" \
-H "Referer: https://api.cms.footlight.io/export")
slug=$(echo "$response" | jq -r '.slug')
echo "CALENDAR_SLUG=$slug" >> $GITHUB_OUTPUT
- name: Export entities
run: |
curl -X 'GET' \
'https://api.cms.footlight.io/entities/export?file-format=ttl&entity=Event' \
-H 'accept: */*' \
-H 'calendar-id: ${{inputs.calendar_id}}' \
-H 'Referer: https://api.cms.footlight.io/export' \
-H 'Authorization: Bearer ${{steps.login-step.outputs.ACCESS_TOKEN}}' \
>> events.ttl
curl -X 'GET' \
'https://api.cms.footlight.io/entities/export?file-format=ttl&entity=Person' \
-H 'accept: */*' \
-H 'calendar-id: ${{inputs.calendar_id}}' \
-H 'Referer: https://api.cms.footlight.io/export' \
-H 'Authorization: Bearer ${{steps.login-step.outputs.ACCESS_TOKEN}}' \
>> people.ttl
curl -X 'GET' \
'https://api.cms.footlight.io/entities/export?file-format=ttl&entity=Organization' \
-H 'accept: */*' \
-H 'calendar-id: ${{inputs.calendar_id}}' \
-H 'Referer: https://api.cms.footlight.io/export' \
-H 'Authorization: Bearer ${{steps.login-step.outputs.ACCESS_TOKEN}}' \
>> organizations.ttl
curl -X 'GET' \
'https://api.cms.footlight.io/entities/export?file-format=ttl&entity=Place' \
-H 'accept: */*' \
-H 'calendar-id: ${{inputs.calendar_id}}' \
-H 'Referer: https://api.cms.footlight.io/export' \
-H 'Authorization: Bearer ${{steps.login-step.outputs.ACCESS_TOKEN}}' \
>> places.ttl
- name: Concatenate the files
run : |
cat \
events.ttl \
places.ttl \
organizations.ttl \
people.ttl \
> ${{steps.get-calendar-slug.outputs.CALENDAR_SLUG}}.ttl
- name: Upload entities in RDF to S3
uses: keithweaver/[email protected]
with:
command: cp
source: ${{steps.get-calendar-slug.outputs.CALENDAR_SLUG}}.ttl
destination: s3://footlight-cms-entities-exported/
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

import-entities-to-artsdata:
needs: get-rdf-data
runs-on: ubuntu-latest
steps:
- name: Call artsdata pipeline action
uses: culturecreates/[email protected]
with:
artifact: "${{needs.get-rdf-data.outputs.calendar-slug}}v2"
publisher: ${{ secrets.PUBLISHER_URI_GREGORY }}
downloadUrl: "https://footlight-cms-entities-exported.s3.ca-central-1.amazonaws.com/${{needs.get-rdf-data.outputs.calendar-slug}}.ttl"
17 changes: 17 additions & 0 deletions .github/workflows/export-signe-laval-entities-to-artsdatav2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Export Signe Laval calendar to Artsdata

on:
workflow_dispatch:

jobs:
call-export-workflow:
uses: ./.github/workflows/export-cms-entitiesv2.yml
with:
calendar_id: ${{ vars.SIGNE_LAVAL_CALENDAR_ID }}
login_email: ${{ vars.CMS_LOGIN_EMAIL }}
secrets:
PUBLISHER_URI_GREGORY: ${{ secrets.PUBLISHER_URI_GREGORY }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
LOGIN_PASSWORD: ${{ secrets.CMS_LOGIN_PASSWORD }}

16 changes: 16 additions & 0 deletions .github/workflows/export-tout-culture-entities-to-artsdatav2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Export Tout Culture calendar to Artsdata

on:
workflow_dispatch:

jobs:
call-export-workflow:
uses: ./.github/workflows/export-cms-entitiesv2.yml
with:
calendar_id: ${{ vars.TOUT_CULTURE_CALENDAR_ID }}
login_email: ${{ vars.CMS_LOGIN_EMAIL }}
secrets:
PUBLISHER_URI_GREGORY: ${{ secrets.PUBLISHER_URI_GREGORY }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
LOGIN_PASSWORD: ${{ secrets.CMS_LOGIN_PASSWORD }}

0 comments on commit dfc91dc

Please sign in to comment.