63 lines
1.9 KiB
YAML
63 lines
1.9 KiB
YAML
name: Scheduled Calendar Scraping
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0 * * *' # Runs daily at midnight UTC
|
|
workflow_dispatch:
|
|
inputs:
|
|
year:
|
|
description: 'Year to scrape (optional, defaults to current BS year)'
|
|
required: false
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
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: |
|
|
MANUAL_YEAR="${{ github.event.inputs.year }}"
|
|
|
|
if [ -n "$MANUAL_YEAR" ]; then
|
|
echo "Using manually specified year: $MANUAL_YEAR"
|
|
uv run scraper.py $MANUAL_YEAR --dir
|
|
else
|
|
# Calculate approximate BS year (Shell logic)
|
|
AD_YEAR=$(date +%Y)
|
|
AD_MONTH=$(date +10%m | sed 's/10//') # Strips leading zero
|
|
AD_DAY=$(date +10%d | sed 's/10//')
|
|
|
|
BS_YEAR=$((AD_YEAR + 56))
|
|
if [ "$AD_MONTH" -gt 4 ] || ([ "$AD_MONTH" -eq 4 ] && [ "$AD_DAY" -ge 14 ]); then
|
|
BS_YEAR=$((BS_YEAR + 1))
|
|
fi
|
|
echo "$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
|
|
uv run scraper.py $BS_YEAR --dir
|
|
fi
|
|
|
|
- name: Commit and push changes
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add data/
|
|
git commit -m "Automated update of Nepali calendar data" || exit 0
|
|
git pull --rebase origin main
|
|
git push
|