|
| 1 | +name: Deploy Firebase Hosting |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +env: |
| 13 | + ARCANE_JASPR_REF: b896cdc28008ef56439f10670a177943c7aba69e |
| 14 | + FIREBASE_PROJECT_ID: holoui-editor |
| 15 | + FIREBASE_TOOLS_VERSION: 15.25.1 |
| 16 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 17 | + NODE_VERSION: 22.23.1 |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: firebase-hosting-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + deploy: |
| 25 | + name: Build, verify, and deploy |
| 26 | + runs-on: ubuntu-latest |
| 27 | + environment: |
| 28 | + name: production |
| 29 | + url: https://holoui-editor.web.app |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v6 |
| 34 | + |
| 35 | + - name: Cache pinned Arcane Jaspr |
| 36 | + id: cache-arcane-jaspr |
| 37 | + uses: actions/cache@v5 |
| 38 | + with: |
| 39 | + path: .deps/arcane_jaspr |
| 40 | + key: arcane-jaspr-${{ env.ARCANE_JASPR_REF }} |
| 41 | + |
| 42 | + - name: Checkout pinned Arcane Jaspr |
| 43 | + if: steps.cache-arcane-jaspr.outputs.cache-hit != 'true' |
| 44 | + uses: actions/checkout@v6 |
| 45 | + with: |
| 46 | + repository: ArcaneArts/arcane_jaspr |
| 47 | + ref: ${{ env.ARCANE_JASPR_REF }} |
| 48 | + path: .deps/arcane_jaspr |
| 49 | + |
| 50 | + - name: Setup Dart |
| 51 | + uses: dart-lang/setup-dart@v1 |
| 52 | + with: |
| 53 | + sdk: stable |
| 54 | + |
| 55 | + - name: Setup Node |
| 56 | + uses: actions/setup-node@v6 |
| 57 | + with: |
| 58 | + node-version: ${{ env.NODE_VERSION }} |
| 59 | + |
| 60 | + - name: Get dependencies |
| 61 | + run: dart pub get |
| 62 | + |
| 63 | + - name: Analyze |
| 64 | + run: dart analyze |
| 65 | + |
| 66 | + - name: Test |
| 67 | + run: dart test |
| 68 | + |
| 69 | + - name: Build |
| 70 | + run: dart run jaspr_cli:jaspr build |
| 71 | + |
| 72 | + - name: Authenticate to Google Cloud |
| 73 | + uses: google-github-actions/auth@v3 |
| 74 | + with: |
| 75 | + credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_HOLOUI_EDITOR }} |
| 76 | + |
| 77 | + - name: Deploy Firebase Hosting |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + unset FIREBASE_TOKEN |
| 81 | + npx --yes "firebase-tools@$FIREBASE_TOOLS_VERSION" deploy \ |
| 82 | + --only hosting \ |
| 83 | + --project "$FIREBASE_PROJECT_ID" \ |
| 84 | + --non-interactive |
| 85 | +
|
| 86 | + - name: Verify deployed bundle |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | + expected_sha="$(sha256sum build/jaspr/main.client.dart.js | awk '{print $1}')" |
| 90 | + actual_sha="" |
| 91 | + for attempt in {1..12}; do |
| 92 | + if actual_sha="$(curl -fsS --max-time 30 \ |
| 93 | + "https://holoui-editor.web.app/main.client.dart.js?release=$GITHUB_SHA" \ |
| 94 | + | sha256sum | awk '{print $1}')" \ |
| 95 | + && [[ "$actual_sha" == "$expected_sha" ]]; then |
| 96 | + echo "Firebase is serving the client bundle built from $GITHUB_SHA." |
| 97 | + exit 0 |
| 98 | + fi |
| 99 | + echo "Waiting for Firebase Hosting to converge (attempt $attempt/12)." |
| 100 | + sleep 5 |
| 101 | + done |
| 102 | + echo "::error title=Stale Firebase client bundle::Expected $expected_sha but received $actual_sha." |
| 103 | + exit 1 |
0 commit comments