Sync classroom timetables #14235
This file contains hidden or 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: Sync classroom timetables | |
| on: | |
| # Triggers this workflow on pushes to the default branch (main) | |
| push: | |
| branches: ["main"] | |
| # Schedule this workflow to run every 30 minutes | |
| schedule: | |
| - cron: "*/30 * * * *" | |
| # Enables manual execution of this workflow from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Update package list | |
| run: sudo apt update | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| - name: Install required Python packages | |
| run: pip install requests bs4 pytz | |
| - name: Run classroom timetables sync script | |
| run: python _scripts/scrape-classroom-timetables.py | |
| working-directory: ${{ github.workspace }} | |
| - name: Check if there are any changes | |
| id: verify_diff | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit | |
| if: steps.verify_diff.outputs.changed == 'true' | |
| 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 "Sync classroom timetables" | |
| git push |