Skip to content

Update Scrolls Data #3477

Update Scrolls Data

Update Scrolls Data #3477

name: Update Scrolls Data
on:
schedule:
- cron: '0 * * * *' # Runs every hour
workflow_dispatch:
jobs:
update_scrolls_data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r scrape_sheets/requirements.txt
- name: Run Python script to update scrolls data
id: scrape_script
run: |
output=$(python3 scrape_sheets/scrape_sheet.py) || echo "No changes detected"
echo "changed_shelfmarks=$output" >> $GITHUB_ENV
echo "::set-output name=changed_shelfmarks::$output"
- name: Commit and push if there are changes
if: ${{ steps.scrape_script.outcome == 'success' }}
run: |
git config --global user.name 'Cole Crawford'
git config --global user.email 'cole_crawford@fas.harvard.edu'
git add -A
if [ "${{ steps.scrape_script.outputs.changed_shelfmarks }}" == "No changes detected." ]; then
echo "No changes to commit."
exit 0
else
git commit -m "Scrolls updated: ${{ steps.scrape_script.outputs.changed_shelfmarks }}" || echo "No changes to commit, exiting..."
# Using the PAT to authenticate the push if commit is successful
git push https://${{ secrets.SCROLLS_CI_PAT }}@github.com/artshumrc/scrolls-astro.git
fi
- name: Trigger Repository Dispatch
if: ${{ steps.scrape_script.outcome == 'success' && steps.scrape_script.outputs.changed_shelfmarks != 'No changes detected.' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.SCROLLS_CI_PAT }}
repository: artshumrc/scrolls-astro
event-type: build-trigger