Skip to content

daily jobs

daily jobs #11

Workflow file for this run

name: daily jobs
run-name: daily jobs
on:
schedule:
# GitHub Actions uses UTC. 20:55 UTC == 04:55 Asia/Taipei (次日).
- cron: "55 20 * * *"
workflow_dispatch:
pull_request:
branches: [ main ]
concurrency:
group: daily-jobs-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
crawler-demo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v1
with:
python-version: "3.12"
- name: Install unar (portable for GitHub + act)
run: |
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
if command -v sudo >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y unar rsync
else
apt-get update
apt-get install -y unar rsync
fi
- name: Download latest rar via unar script
working-directory: tools
run: |
set -euo pipefail
chmod +x download.sh
./download.sh
- name: Sync env with uv
working-directory: tools
run: |
set -euo pipefail
uv sync
- name: Run main.py
working-directory: tools
run: |
set -euo pipefail
# 輸出寫回 repo 根目錄
uv run python main.py --dir data -o ../courses.json --pretty
- name: Configure Git identity
if: ${{ github.event_name != 'pull_request' }}
run: |
set -euo pipefail
git config --global user.name "crawler-bot"
git config --global user.email "crawler-bot@tku.edu"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Force commit (always, even if no changes)
if: ${{ github.event_name != 'pull_request' }}
run: |
set -euo pipefail
git add -A || true
git commit --allow-empty -m "daily crawl: $(date -u +'%Y-%m-%dT%H:%M:%SZ')" || true
- name: Pull rebase and push (simple)
if: ${{ github.event_name != 'pull_request' }}
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
git fetch origin "$BRANCH_NAME"
git pull --rebase origin "$BRANCH_NAME"
git push origin "HEAD:$BRANCH_NAME"