Data Generation #233
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: Data Generation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "generation/**" | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * 0" | |
| concurrency: | |
| group: "generation" | |
| cancel-in-progress: true | |
| jobs: | |
| generate: | |
| name: Generate Data | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./generation | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.12 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install Dependencies | |
| run: uv sync | |
| - name: Setup Cache Environment | |
| run: echo "cache_id=$(date --utc '+%U')" >> $GITHUB_ENV | |
| - name: Cache Generation | |
| uses: actions/cache@v4 | |
| with: | |
| path: generation/.cache | |
| key: generation-${{ runner.os }}-${{ env.cache_id }} | |
| - name: Generate Data | |
| run: uv run python main.py --step all | |
| env: | |
| DATA_DIR: "../data" | |
| SITEMAP_BASE: ${{ vars.BASE_URL }} | |
| MADGRADES_API_KEY: ${{ secrets.MADGRADES_API_KEY }} | |
| - name: Upload Data | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: uw-coursemap-data-snapshot-${{ github.run_id }} | |
| path: data/ | |
| include-hidden-files: "true" | |
| deployment: | |
| name: Deploy Data Snapshot | |
| needs: generate | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| environment: | |
| name: static-data | |
| url: ${{ vars.DEPLOY_URL }} | |
| steps: | |
| - name: Checkout Deployment Repo | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: twangodev/uw-coursemap-data | |
| token: ${{ secrets.PAT }} | |
| path: deploy | |
| - name: Download Generated Snapshot | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: uw-coursemap-data-snapshot-${{ github.run_id }} | |
| path: snapshot | |
| - name: Replace with Snapshot | |
| run: | | |
| cd deploy | |
| rsync -a --delete --exclude='.git' ../snapshot/ . | |
| rm -rf ../snapshot | |
| - name: Commit Snapshot | |
| id: commit | |
| uses: stefanzweifel/git-auto-commit-action@v7 | |
| with: | |
| repository: "deploy" | |
| disable_globbing: true | |
| commit_message: "Deploy Snapshot #${{ github.run_id }}" | |
| branch: main | |
| push_options: "--force" | |
| bump: | |
| name: Bump Submodule | |
| needs: deployment | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Bump Submodule | |
| run: git submodule update --remote | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| title: "Bump Data Submodule from Snapshot #${{ github.run_id }}" | |
| base: main | |
| branch: "github-actions/data-bump" | |
| sign-commits: "true" | |
| commit-message: "Bump Data Submodule from Snapshot #${{ github.run_id }}" | |
| labels: submodules, cicd, generation | |
| reviewers: ${{ github.repository_owner }} |