update data.json #2698
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: update data.json | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 * * * *" | |
jobs: | |
scrape_and_save: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run scraping script | |
env: | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
DATABASE_ID: ${{ secrets.DATABASE_ID }} | |
run: | | |
python scripts/scrape.py | |
- name: Commit data.json | |
run: | | |
git diff --quiet --exit-code public/assets/data.json || ( | |
git config --global user.name "NowScott" | |
git config --global user.email "[email protected]" | |
git add public/assets/data.json | |
DATE=$(TZ="Asia/Shanghai" date "+%Y-%m-%d %H:%M:%S") | |
git commit -m "Update data.json at $DATE" | |
git push origin main | |
) | |