Skip to content

Commit

Permalink
Updates kiac crawl to use reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-aravind committed Sep 2, 2024
1 parent af87a72 commit 9e3f75c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 72 deletions.
47 changes: 12 additions & 35 deletions .github/workflows/fetch-and-push-to-artsdata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable workflow to push into artsdata
name: Reusable workflow to fetch JSON-LD data.

on:
workflow_call:
Expand All @@ -15,23 +15,16 @@ on:
is_paginated:
required: true
type: string
base_url:
required: false
type: string
artifact_name:
headless:
required: true
type: string
href:
required: false
type: string
secrets:
publisher_uri:
required: true


jobs:
fetch-data:
fetch-and-commit-data:
runs-on: ubuntu-latest
outputs:
commit-hash: ${{ steps.get_commit_hash.outputs.commit-hash }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
Expand All @@ -49,36 +42,20 @@ jobs:
"${{ inputs.entity_identifier }}" \
output/${{ inputs.file_name }} \
${{ inputs.is_paginated}} \
${{ inputs.base_url}} \
${{inputs.href}}
${{ inputs.headless}} \
- name: Commit and Push Changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git pull
git add "output/${{ inputs.file_name }}"
git commit -m "Add data generated by the script"
git push
- name: Set current date as output
id: version
run: echo "dumpdate=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_OUTPUT

- name: Set download URL
id: output_file
run: echo "download_url=https://raw.githubusercontent.com/culturecreates/artsdata-orion/main/output/${{ inputs.file_name }}" >> $GITHUB_OUTPUT
- name: Push to artsdata
- name: Get commit hash
id: get_commit_hash
run: |
curl \
-H 'Content-Type: application/json' \
-X POST http://api.artsdata.ca/databus/ \
--data '{ "artifact": "${{ inputs.artifact_name }}",
"comment": "Entities from ${{ inputs.page_url }}",
"publisher": "${{ secrets.publisher_uri }}",
"group": "${{ github.event.repository.name }}",
"version": "${{ steps.version.outputs.dumpdate }}",
"downloadUrl": "${{ steps.output_file.outputs.download_url }}",
"downloadFile": "${{ github.event.inputs.file_name }}",
"reportCallbackUrl": "https://huginn-staging.herokuapp.com/users/1/web_requests/273/databus"
}'
commit_hash=$(git rev-parse HEAD)
echo "commit-hash=$commit_hash" >> $GITHUB_OUTPUT
47 changes: 10 additions & 37 deletions .github/workflows/kiac-events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,22 @@ on:
- cron: '0 0 1 * *'

jobs:
fetch-and-commit-data:
runs-on: ubuntu-latest
outputs:
commit-hash: ${{ steps.get_commit_hash.outputs.commit-hash }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run Main Script
run: |
bundle exec ruby src/main.rb \
https://kiac.ca/calendar-of-events/ \
"div.tribe-events-pro-photo__event-featured-image-wrapper a" \
output/kiac-events.jsonld \
false
- name: Commit and Push Changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git pull
git add "output/kiac-events.jsonld"
git commit -m "Add data generated by the script"
git push
- name: Get commit hash
id: get_commit_hash
run: |
commit_hash=$(git rev-parse HEAD)
echo "commit-hash=$commit_hash" >> $GITHUB_OUTPUT
call-workflow-to-fetch-data:
uses: ./.github/workflows/fetch-and-push-to-artsdata.yml
with:
page_url: "https://kiac.ca/calendar-of-events/"
entity_identifier: "div.tribe-events-pro-photo__event-featured-image-wrapper a"
file_name: "kiac-events.jsonld"
is_paginated: "false"
headless: "false"

artsdata-push:
runs-on: ubuntu-latest
needs: fetch-and-commit-data
needs: call-workflow-to-fetch-data
steps:
- name: Action setup
uses: culturecreates/[email protected]
with:
artifact: kiac-ca
publisher: "${{ secrets.PUBLISHER_URI_GREGORY }}"
downloadUrl: https://raw.githubusercontent.com/culturecreates/artsdata-orion/${{ needs.fetch-and-commit-data.outputs.commit-hash }}/output/kiac-events.jsonld
downloadUrl: https://raw.githubusercontent.com/culturecreates/artsdata-orion/${{ needs.call-workflow-to-fetch-data.outputs.commit-hash }}/output/kiac-events.jsonld

0 comments on commit 9e3f75c

Please sign in to comment.