chore: export frontend static assets #2
Workflow file for this run
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: Require Frontend Export | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - "frontend/**" | |
| - "scripts/export_frontend.sh" | |
| - "src/hyperview/server/static/**" | |
| push: | |
| paths: | |
| - "frontend/**" | |
| - "scripts/export_frontend.sh" | |
| - "src/hyperview/server/static/**" | |
| jobs: | |
| require-frontend-export: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify static export updated when frontend changes | |
| run: | | |
| set -euo pipefail | |
| # Determine base and head SHAs based on event type | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| base_sha="${{ github.event.pull_request.base.sha }}" | |
| head_sha="${{ github.event.pull_request.head.sha }}" | |
| else | |
| # For push events, compare with the previous commit | |
| head_sha="${{ github.sha }}" | |
| base_sha="${{ github.event.before }}" | |
| # Handle initial push (no previous commit) | |
| if [[ "$base_sha" == "0000000000000000000000000000000000000000" ]]; then | |
| echo "Initial push - skipping check" | |
| exit 0 | |
| fi | |
| fi | |
| changed_files="$(git diff --name-only "$base_sha" "$head_sha")" | |
| echo "Changed files:" | |
| echo "$changed_files" | |
| frontend_changed="false" | |
| static_changed="false" | |
| if echo "$changed_files" | grep -qE '^(frontend/|scripts/export_frontend\.sh$)'; then | |
| frontend_changed="true" | |
| fi | |
| if echo "$changed_files" | grep -q '^src/hyperview/server/static/'; then | |
| static_changed="true" | |
| fi | |
| if [[ "$frontend_changed" == "true" && "$static_changed" != "true" ]]; then | |
| echo "" | |
| echo "ERROR: frontend/ changed but src/hyperview/server/static/ was not updated." | |
| echo "Run: bash scripts/export_frontend.sh" | |
| echo "Then commit the updated src/hyperview/server/static/ output." | |
| exit 1 | |
| fi | |
| echo "OK: export requirements satisfied." |