Merge pull request #1993 from harvard-edge/dependabot/uv/mlperf-edu/c… #5
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: 'MLPerf EDU · Preview (Dev)' | |
| # Builds the independent review site and deploys it to the existing development | |
| # preview repository. Deployment requires the same external configuration as the | |
| # other preview sites in this repository. | |
| # | |
| # Required secret: SSH_DEPLOY_KEY | |
| # Required variable: DEV_REPO_URL | |
| # Preview path: /mlperf-edu/ | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [dev] | |
| paths: | |
| - 'mlperf-edu/**' | |
| - '.github/workflows/mlperf-edu-*.yml' | |
| permissions: | |
| contents: read | |
| actions: read | |
| concurrency: | |
| group: mlperf-edu-dev-deploy | |
| cancel-in-progress: true | |
| env: | |
| MLPERF_EDU_ROOT: mlperf-edu | |
| MLPERF_EDU_DEPLOY_PATH: mlperf-edu | |
| jobs: | |
| validate: | |
| name: 'Validate the Preview' | |
| uses: ./.github/workflows/mlperf-edu-validate-dev.yml | |
| build-and-deploy: | |
| name: 'Build and Deploy the Dev Preview' | |
| runs-on: ubuntu-latest | |
| needs: [validate] | |
| timeout-minutes: 25 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set Up uv and Python | |
| uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 | |
| with: | |
| python-version: '3.12' | |
| enable-cache: true | |
| cache-dependency-glob: '${{ env.MLPERF_EDU_ROOT }}/uv.lock' | |
| working-directory: ${{ env.MLPERF_EDU_ROOT }} | |
| - name: Set Up Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| - name: Install the Locked Environment | |
| working-directory: ${{ env.MLPERF_EDU_ROOT }} | |
| run: uv sync --locked --extra dev | |
| - name: Build the Review Site | |
| working-directory: ${{ env.MLPERF_EDU_ROOT }} | |
| run: | | |
| uv run python tools/generate_docs.py --check | |
| quarto render site | |
| touch site/_build/.nojekyll | |
| # Quarto emits relative links for this standalone project, so it remains | |
| # valid under /mlperf-edu/ without the shared ecosystem URL rewriter. | |
| - name: Check External Deployment Configuration | |
| shell: bash | |
| env: | |
| SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
| DEV_REPO_URL: ${{ vars.DEV_REPO_URL }} | |
| run: | | |
| set -euo pipefail | |
| test -n "$SSH_DEPLOY_KEY" || { echo 'SSH_DEPLOY_KEY is required for preview deployment.'; exit 1; } | |
| test -n "$DEV_REPO_URL" || { echo 'DEV_REPO_URL is required for preview deployment.'; exit 1; } | |
| - name: Deploy to the Development Preview Repository | |
| shell: bash | |
| env: | |
| SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
| DEV_REPO_URL: ${{ vars.DEV_REPO_URL }} | |
| run: | | |
| set -euo pipefail | |
| eval "$(ssh-agent -s)" | |
| echo "$SSH_DEPLOY_KEY" | tr -d '\r' | ssh-add - >/dev/null | |
| mkdir -p ~/.ssh | |
| ssh-keyscan github.com >> ~/.ssh/known_hosts | |
| git config --global user.email 'actions@github.com' | |
| git config --global user.name 'GitHub Actions' | |
| git clone --depth=1 "$DEV_REPO_URL" target-repo | |
| cd target-repo | |
| rm -rf "$MLPERF_EDU_DEPLOY_PATH" | |
| mkdir -p "$MLPERF_EDU_DEPLOY_PATH" | |
| cp -r "$GITHUB_WORKSPACE/$MLPERF_EDU_ROOT/site/_build/." "$MLPERF_EDU_DEPLOY_PATH/" | |
| test -f "$MLPERF_EDU_DEPLOY_PATH/index.html" | |
| git add "$MLPERF_EDU_DEPLOY_PATH" | |
| git commit -m "Deploy MLPerf EDU dev preview from ${{ github.sha }}" --allow-empty | |
| for attempt in 1 2 3; do | |
| if git push origin main; then | |
| exit 0 | |
| fi | |
| echo "Push attempt $attempt failed. Rebasing before retry." | |
| git pull --rebase origin main | |
| done | |
| echo 'Preview deployment failed after three attempts.' | |
| exit 1 |