Skip to content

chore: sync main from private to public repository #2

chore: sync main from private to public repository

chore: sync main from private to public repository #2

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on PR
on:
pull_request:
branches:
- dev
- main
- release/*
workflow_dispatch:
jobs:
build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Shortify commit sha
shell: bash
run: echo "sha_short=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT
id: shortify_commit
- name: Get branch
shell: bash
run: echo "ref_short=$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
id: get_branch
- name: Get Preview Channel ID
shell: bash
run: echo "preview_channel_id=$(echo ${GITHUB_REF#*/})" >> $GITHUB_OUTPUT
id: get_preview_channel_id
- name: Setup GH Actions
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Get stable flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.22.x"
channel: "stable"
- name: Prepare build directory
run: |
flutter clean
rm -rf build/*
rm -rf web/src/mm2/*
rm -rf web/src/kdfi/*
rm -rf web/dist/*
- name: Fetch packages and generate assets
run: |
echo "Running \`flutter build\` to generate assets for the deployment build"
flutter pub get > /dev/null 2>&1
flutter build web --release > /dev/null 2>&1 || true
flutter pub get > /dev/null 2>&1
echo "Done fetching packages and generating assets"
- name: Build Komodo Wallet web
run: |
flutter doctor
# https://github.com/flutter/flutter/issues/60069#issuecomment-1913588937
flutter build web --csp --no-web-resources-cdn
- name: Validate build
run: |
# Check that the web build folder contains a wasm file in the format build/web/dist/*.wasm
if [ ! -f build/web/dist/*.wasm ]; then
echo "Error: Web build failed. No wasm file found in build/web/dist/"
# List files for debugging
echo "Listing files in build/web recursively"
ls -R build/web
echo "Listing files in web recursively"
ls -R web
exit 1
fi
# Check that the index.html is present and that it is equal to the source index.html
if ! cmp -s web/index.html build/web/index.html; then
echo "Error: Web build failed. index.html is not equal to the source index.html"
exit 1
fi
# Check that the index.html has uncommitted changes to ensure that the placeholder was replaced with the generated content
if git diff --exit-code web/index.html; then
echo "Error: Web build failed. index.html has no uncommitted changes which indicates an issue with the \`template.html\` to \`index.html\` generation"
exit 1
fi
# Decode the AssetManifest.bin and check for the coin icon presence
if [ ! -f build/web/assets/AssetManifest.bin ]; then
echo "Error: AssetManifest.bin file not found."
exit 1
fi
if ! strings build/web/assets/AssetManifest.bin | grep -q "assets/coin_icons/png/kmd.png"; then
echo "Error: Coin icon not found in AssetManifest.bin"
exit 1
fi
- name: Deploy Komodo Wallet web feature preview (Expires in 7 days)
uses: FirebaseExtended/[email protected]
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KOMODO_WALLET_OFFICIAL }}"
channelId: "${{ steps.get_preview_channel_id.outputs.preview_channel_id }}"
target: walletrc
expires: 7d
projectId: komodo-wallet-official
- name: Deploy Komodo Wallet Web dev preview (`dev` branch)
if: github.ref == 'refs/heads/dev' && github.event_name != 'workflow_dispatch'
uses: FirebaseExtended/[email protected]
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KOMODO_WALLET_OFFICIAL }}"
channelId: dev-preview
target: walletrc
projectId: komodo-wallet-official