50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
name: Scheduled Calendar Scraping
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0 * * *' # Runs daily at midnight UTC
|
|
workflow_dispatch: # Allows manual triggering
|
|
|
|
jobs:
|
|
scrape:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
|
|
- name: Set up Python
|
|
run: uv python install 3.13
|
|
|
|
- name: Determine current Nepali year and run scraper
|
|
run: |
|
|
# Calculate current BS year (approximate logic for scheduling)
|
|
# BS year = AD year + 56 (for most months) or 57 (after mid-April)
|
|
python3 -c "
|
|
import datetime
|
|
now = datetime.datetime.now()
|
|
# Approx Nepali New Year is April 14
|
|
bs_year = now.year + 56
|
|
if now.month > 4 or (now.month == 4 and now.day >= 14):
|
|
bs_year += 1
|
|
print(bs_year)
|
|
" > bs_year.txt
|
|
|
|
BS_YEAR=$(cat bs_year.txt)
|
|
echo "Current Nepali Year (approx): $BS_YEAR"
|
|
|
|
# Run the scraper for the current year (and maybe the next to be safe)
|
|
uv run scraper.py $BS_YEAR --dir
|
|
NEXT_YEAR=$((BS_YEAR + 1))
|
|
uv run scraper.py $NEXT_YEAR --dir
|
|
|
|
- name: Commit and push changes
|
|
run: |
|
|
git config --global user.name "GitHub Action"
|
|
git config --global user.email "action@github.com"
|
|
git add data/
|
|
git commit -m "Automated update of Nepali calendar data" || exit 0
|
|
git push
|