-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.81 KB
/
update_scrolls_data.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 '[email protected]'
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