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: Install Python 3.13 run: uv python install 3.13 - name: Determine current Nepali year and run scraper run: | set -e # Exit immediately if a command fails MANUAL_YEAR="${{ github.event.inputs.year }}" if [ -n "$MANUAL_YEAR" ]; then echo "Using manually specified year: $MANUAL_YEAR" uv run python scraper.py "$MANUAL_YEAR" --dir else # Calculate approximate current BS year BS_YEAR=$(python3 - << 'EOF' import datetime now = datetime.datetime.now() bs_year = now.year + 56 if now.month > 4 or (now.month == 4 and now.day >= 14): bs_year += 1 print(bs_year) EOF ) echo "Current Nepali Year (approx): $BS_YEAR" # Run scraper for current and next year uv run python scraper.py "$BS_YEAR" --dir NEXT_YEAR=$((BS_YEAR + 1)) uv run python scraper.py "$NEXT_YEAR" --dir fi - 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 diff-index --quiet HEAD || git commit -m "Automated update of Nepali calendar data" git push