|
16 | 16 | jobs: |
17 | 17 | require-frontend-export: |
18 | 18 | runs-on: ubuntu-latest |
| 19 | + if: github.actor != 'github-actions[bot]' |
| 20 | + permissions: |
| 21 | + contents: write |
19 | 22 |
|
20 | 23 | steps: |
21 | 24 | - name: Checkout repository |
22 | 25 | uses: actions/checkout@v4 |
23 | 26 | with: |
24 | 27 | fetch-depth: 0 |
25 | 28 |
|
26 | | - - name: Verify static export updated when frontend changes |
| 29 | + - name: Detect frontend and static changes |
| 30 | + id: changes |
27 | 31 | run: | |
28 | 32 | set -euo pipefail |
29 | 33 |
|
|
58 | 62 | static_changed="true" |
59 | 63 | fi |
60 | 64 |
|
| 65 | + needs_export="false" |
| 66 | + if [[ "$frontend_changed" == "true" && "$static_changed" != "true" ]]; then |
| 67 | + needs_export="true" |
| 68 | + fi |
| 69 | +
|
| 70 | + { |
| 71 | + echo "frontend_changed=$frontend_changed" |
| 72 | + echo "static_changed=$static_changed" |
| 73 | + echo "needs_export=$needs_export" |
| 74 | + } >> "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | + - name: Set up Node |
| 77 | + if: ${{ github.event_name == 'push' && steps.changes.outputs.needs_export == 'true' }} |
| 78 | + uses: actions/setup-node@v4 |
| 79 | + with: |
| 80 | + node-version: 20 |
| 81 | + |
| 82 | + - name: Export frontend |
| 83 | + if: ${{ github.event_name == 'push' && steps.changes.outputs.needs_export == 'true' }} |
| 84 | + run: | |
| 85 | + bash scripts/export_frontend.sh |
| 86 | +
|
| 87 | + - name: Commit exported static assets |
| 88 | + if: ${{ github.event_name == 'push' && steps.changes.outputs.needs_export == 'true' }} |
| 89 | + run: | |
| 90 | + set -euo pipefail |
| 91 | +
|
| 92 | + if [[ -z "$(git status --porcelain)" ]]; then |
| 93 | + echo "No export changes to commit." |
| 94 | + exit 0 |
| 95 | + fi |
| 96 | +
|
| 97 | + git status --short |
| 98 | + git config user.name "github-actions[bot]" |
| 99 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 100 | + git add src/hyperview/server/static |
| 101 | + git commit -m "chore: export frontend static assets" |
| 102 | + git push |
| 103 | +
|
| 104 | + - name: Verify static export updated when frontend changes |
| 105 | + if: ${{ !(github.event_name == 'push' && steps.changes.outputs.needs_export == 'true') }} |
| 106 | + run: | |
| 107 | + set -euo pipefail |
| 108 | +
|
| 109 | + frontend_changed="${{ steps.changes.outputs.frontend_changed }}" |
| 110 | + static_changed="${{ steps.changes.outputs.static_changed }}" |
| 111 | +
|
61 | 112 | if [[ "$frontend_changed" == "true" && "$static_changed" != "true" ]]; then |
62 | 113 | echo "" |
63 | 114 | echo "ERROR: frontend/ changed but src/hyperview/server/static/ was not updated." |
|
0 commit comments