Skip to content

CharlVS is deploying SDK integration preview with API branch 'master' via github_pages πŸš€ #5

CharlVS is deploying SDK integration preview with API branch 'master' via github_pages πŸš€

CharlVS is deploying SDK integration preview with API branch 'master' via github_pages πŸš€ #5

# Deploy a preview build with SDK integration for testing KDF API changes
# This workflow supports multiple deployment methods with user control:
# - AUTO: Use Firebase if configured, automatically fallback to GitHub Pages if not
# - FIREBASE: Force Firebase deployment (will fail if service account not configured)
# - GITHUB_PAGES: Force GitHub Pages deployment (⚠️ WARNING: Will overwrite existing GitHub Pages!)
name: Deploy SDK Integration Preview
run-name: ${{ github.actor }} is deploying SDK integration preview with API branch '${{ inputs.api_branch }}' via ${{ inputs.deployment_method }} πŸš€
permissions:
contents: read
pages: write
id-token: write
on:
workflow_dispatch:
inputs:
api_branch:
description: "API branch name to update KDF configuration"
required: true
default: "dev"
type: string
sdk_branch:
description: "SDK branch to clone (optional, defaults to dev)"
required: false
default: "dev"
type: string
coins_repo_branch:
description: "Coins repository branch to use (optional, defaults to master)"
required: false
default: "master"
type: string
deployment_method:
description: "⚠️ DEPLOYMENT METHOD: Choose deployment target. AUTO: Use Firebase if configured, fallback to GitHub Pages. FIREBASE: Force Firebase (will fail if not configured). GITHUB_PAGES: ⚠️ WARNING: Will OVERWRITE existing GitHub Pages deployment of this repository! Use only if you understand the consequences."
required: false
default: "auto"
type: choice
options:
- "auto"
- "firebase"
- "github_pages"
jobs:
sdk_integration_preview:
runs-on: ubuntu-latest
outputs:
preview_url: ${{ steps.deploy_result.outputs.preview_url }}
channel_id: ${{ steps.deploy_result.outputs.channel_id }}
deployment_method: ${{ steps.deploy_result.outputs.deployment_method }}
deployment_method_input: ${{ inputs.deployment_method }}
api_branch: ${{ inputs.api_branch }}
sdk_branch: ${{ inputs.sdk_branch }}
coins_branch: ${{ inputs.coins_repo_branch }}
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=sdk-integration-${{ inputs.api_branch }}-$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT
id: get_preview_channel_id
- name: Setup GH Actions
uses: actions/checkout@v4
- name: Install Flutter and dependencies
uses: ./.github/actions/flutter-deps
- name: Clone SDK repository
shell: bash
run: |
echo "Cloning komodo-defi-sdk-flutter repository..."
git clone --depth 1 --branch ${{ inputs.sdk_branch }} https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git sdk
echo "SDK cloned to ./sdk directory"
ls -la sdk/
- name: Update KDF API configuration
shell: bash
run: |
echo "Updating KDF API configuration for branch: ${{ inputs.api_branch }}"
cd sdk
# Check if the update script exists
if [ -f "packages/komodo_wallet_cli/bin/update_api_config.dart" ]; then
echo "Running update_api_config.dart script..."
# Install dart dependencies first
cd packages/komodo_wallet_cli
dart pub get
cd ../..
# Run the update script with the API branch
dart run packages/komodo_wallet_cli/bin/update_api_config.dart \
--branch ${{ inputs.api_branch }} \
--source mirror \
--config packages/komodo_defi_framework/app_build/build_config.json \
--output-dir packages/komodo_defi_framework/app_build/temp_downloads \
--verbose
echo "KDF API configuration updated successfully"
else
echo "Warning: update_api_config.dart script not found at packages/komodo_wallet_cli/bin/update_api_config.dart"
echo "Available files in packages/komodo_wallet_cli/bin/:"
ls -la packages/komodo_wallet_cli/bin/ || echo "Directory not found"
fi
- name: Update coins configuration
shell: bash
run: |
echo "Updating coins configuration to use branch: ${{ inputs.coins_repo_branch }}"
# Update the build config file to use the specified coins repo branch
if [ -f "sdk/packages/komodo_defi_framework/app_build/build_config.json" ]; then
echo "Updating build_config.json to use coins branch: ${{ inputs.coins_repo_branch }}"
# Create backup
cp sdk/packages/komodo_defi_framework/app_build/build_config.json sdk/packages/komodo_defi_framework/app_build/build_config.json.backup
# Update the coins repo branch using jq
jq --arg branch "${{ inputs.coins_repo_branch }}" \
'.coins.coins_repo_branch = $branch' \
sdk/packages/komodo_defi_framework/app_build/build_config.json > temp_config.json && \
mv temp_config.json sdk/packages/komodo_defi_framework/app_build/build_config.json
# Update CDN mirrors if the branch is master or main
if [[ "${{ inputs.coins_repo_branch }}" == "master" || "${{ inputs.coins_repo_branch }}" == "main" ]]; then
echo "Adding CDN mirror for branch: ${{ inputs.coins_repo_branch }}"
jq --arg branch "${{ inputs.coins_repo_branch }}" \
'.coins.cdn_branch_mirrors[$branch] = "https://komodoplatform.github.io/coins"' \
sdk/packages/komodo_defi_framework/app_build/build_config.json > temp_config.json && \
mv temp_config.json sdk/packages/komodo_defi_framework/app_build/build_config.json
fi
echo "Updated build_config.json with coins branch: ${{ inputs.coins_repo_branch }}"
echo "=== Coins configuration ==="
jq '.coins' sdk/packages/komodo_defi_framework/app_build/build_config.json
else
echo "Warning: build_config.json not found, using default coins configuration"
fi
- name: Update pubspec.yaml to use local SDK paths
shell: bash
run: |
echo "Updating pubspec.yaml files to use local SDK paths..."
# Update main pubspec.yaml
echo "Updating main pubspec.yaml..."
sed -i 's|komodo_cex_market_data:.*|komodo_cex_market_data:|' pubspec.yaml
sed -i '/komodo_cex_market_data:/,/ref: dev/c\
komodo_cex_market_data:\
path: sdk/packages/komodo_cex_market_data' pubspec.yaml
sed -i 's|komodo_defi_sdk:.*|komodo_defi_sdk:|' pubspec.yaml
sed -i '/komodo_defi_sdk:/,/ref: dev/c\
komodo_defi_sdk:\
path: sdk/packages/komodo_defi_sdk' pubspec.yaml
sed -i 's|komodo_defi_types:.*|komodo_defi_types:|' pubspec.yaml
sed -i '/komodo_defi_types:/,/ref: dev/c\
komodo_defi_types:\
path: sdk/packages/komodo_defi_types' pubspec.yaml
sed -i 's|komodo_ui:.*|komodo_ui:|' pubspec.yaml
sed -i '/komodo_ui:/,/ref: dev/c\
komodo_ui:\
path: sdk/packages/komodo_ui' pubspec.yaml
# Update komodo_ui_kit pubspec.yaml
echo "Updating packages/komodo_ui_kit/pubspec.yaml..."
sed -i 's|komodo_defi_types:.*|komodo_defi_types:|' packages/komodo_ui_kit/pubspec.yaml
sed -i '/komodo_defi_types:/,/ref: dev/c\
komodo_defi_types:\
path: ../../sdk/packages/komodo_defi_types' packages/komodo_ui_kit/pubspec.yaml
sed -i 's|komodo_ui:.*|komodo_ui:|' packages/komodo_ui_kit/pubspec.yaml
sed -i '/komodo_ui:/,/ref: dev/c\
komodo_ui:\
path: ../../sdk/packages/komodo_ui' packages/komodo_ui_kit/pubspec.yaml
echo "Pubspec.yaml files updated successfully"
# Show the changes made
echo "=== Main pubspec.yaml SDK dependencies ==="
grep -A2 -B1 "komodo_.*:" pubspec.yaml | grep -A2 -B1 "path: sdk"
echo "=== UI Kit pubspec.yaml SDK dependencies ==="
grep -A2 -B1 "komodo_.*:" packages/komodo_ui_kit/pubspec.yaml | grep -A2 -B1 "path: ../../sdk"
- name: Fetch SDK packages
run: |
echo "Fetching KDF SDK packages..."
flutter pub get -C . || echo "Failed to fetch KDF SDK packages, continuing..."
- name: Fetch packages and generate assets
uses: ./.github/actions/generate-assets
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Optionally provide feedback service configuration if available
FEEDBACK_API_KEY: ${{ secrets.FEEDBACK_API_KEY }}
FEEDBACK_PRODUCTION_URL: ${{ secrets.FEEDBACK_PRODUCTION_URL }}
FEEDBACK_TEST_URL: ${{ secrets.FEEDBACK_TEST_URL }}
TRELLO_API_KEY: ${{ secrets.TRELLO_API_KEY }}
TRELLO_TOKEN: ${{ secrets.TRELLO_TOKEN }}
TRELLO_BOARD_ID: ${{ secrets.TRELLO_BOARD_ID }}
TRELLO_LIST_ID: ${{ secrets.TRELLO_LIST_ID }}
- name: Validate build
uses: ./.github/actions/validate-build
- name: Determine deployment method
id: check_deployment
shell: bash
run: |
echo "🎯 Deployment method input: ${{ inputs.deployment_method }}"
# Check if Firebase is configured
if [ -n "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KOMODO_WALLET_OFFICIAL }}" ]; then
firebase_available=true
echo "βœ… Firebase service account is configured and available"
else
firebase_available=false
echo "❌ Firebase service account is not configured"
fi
# Determine final deployment method based on user input and Firebase availability
case "${{ inputs.deployment_method }}" in
"auto")
if [ "$firebase_available" = true ]; then
echo "deployment_method=firebase" >> $GITHUB_OUTPUT
echo "πŸ”₯ AUTO mode: Using Firebase (available and configured)"
else
echo "deployment_method=github_pages" >> $GITHUB_OUTPUT
echo "πŸ“„ AUTO mode: Using GitHub Pages (Firebase not available)"
fi
;;
"firebase")
if [ "$firebase_available" = true ]; then
echo "deployment_method=firebase" >> $GITHUB_OUTPUT
echo "πŸ”₯ FIREBASE mode: Using Firebase (forced by user)"
else
echo "❌ ERROR: Firebase deployment requested but service account not configured!"
echo "Please configure FIREBASE_SERVICE_ACCOUNT_KOMODO_WALLET_OFFICIAL secret or choose a different deployment method."
exit 1
fi
;;
"github_pages")
echo "deployment_method=github_pages" >> $GITHUB_OUTPUT
echo "⚠️ GITHUB_PAGES mode: Using GitHub Pages (forced by user)"
echo "⚠️ WARNING: This will overwrite any existing GitHub Pages deployment!"
;;
*)
echo "❌ ERROR: Invalid deployment method: ${{ inputs.deployment_method }}"
exit 1
;;
esac
echo "βœ… Final deployment method: $(cat $GITHUB_OUTPUT | grep deployment_method | cut -d'=' -f2)"
- name: Deploy SDK Integration Preview with Firebase (Expires in 7 days)
id: firebase_deploy
if: steps.check_deployment.outputs.deployment_method == 'firebase'
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: Announce Firebase deployment
if: steps.check_deployment.outputs.deployment_method == 'firebase'
shell: bash
run: |
echo "::notice title=πŸ”₯ Firebase Preview Deployed::Preview URL: ${{ steps.firebase_deploy.outputs.details_url }}"
- name: Prepare GitHub Pages deployment
id: prepare_pages
if: steps.check_deployment.outputs.deployment_method == 'github_pages'
shell: bash
run: |
echo "Preparing build for GitHub Pages deployment..."
# Create a deployment directory
mkdir -p pages-deploy
# Copy build output to deployment directory
cp -r build/web/* pages-deploy/
# Create index.html if it doesn't exist (fallback)
if [ ! -f "pages-deploy/index.html" ]; then
echo "Creating fallback index.html"
echo '<!DOCTYPE html>' > pages-deploy/index.html
echo '<html>' >> pages-deploy/index.html
echo '<head>' >> pages-deploy/index.html
echo ' <meta charset="UTF-8">' >> pages-deploy/index.html
echo ' <title>Komodo Wallet SDK Integration Preview</title>' >> pages-deploy/index.html
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">' >> pages-deploy/index.html
echo '</head>' >> pages-deploy/index.html
echo '<body>' >> pages-deploy/index.html
echo ' <h1>Komodo Wallet SDK Integration Preview</h1>' >> pages-deploy/index.html
echo ' <p>This is a preview build with SDK integration.</p>' >> pages-deploy/index.html
echo " <p>API Branch: ${{ inputs.api_branch }}</p>" >> pages-deploy/index.html
echo " <p>SDK Branch: ${{ inputs.sdk_branch }}</p>" >> pages-deploy/index.html
echo " <p>Coins Branch: ${{ inputs.coins_repo_branch }}</p>" >> pages-deploy/index.html
echo '</body>' >> pages-deploy/index.html
echo '</html>' >> pages-deploy/index.html
fi
# Create .nojekyll file to prevent GitHub Pages from processing files starting with _
touch pages-deploy/.nojekyll
echo "GitHub Pages deployment prepared"
ls -la pages-deploy/
- name: Deploy to GitHub Pages
id: pages_deploy
if: steps.check_deployment.outputs.deployment_method == 'github_pages'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./pages-deploy
publish_branch: gh-pages
destination_dir: sdk-integration/${{ steps.get_preview_channel_id.outputs.preview_channel_id }}
force_orphan: false
- name: Announce GitHub Pages deployment
if: steps.check_deployment.outputs.deployment_method == 'github_pages'
shell: bash
run: |
PAGES_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/sdk-integration/${{ steps.get_preview_channel_id.outputs.preview_channel_id }}/"
echo "::notice title=πŸ“„ GitHub Pages Preview Deployed::Preview URL: $PAGES_URL"
- name: Set deployment result
id: deploy_result
shell: bash
run: |
if [ "${{ steps.check_deployment.outputs.deployment_method }}" == "firebase" ]; then
echo "deployment_method=firebase" >> $GITHUB_OUTPUT
echo "preview_url=${{ steps.firebase_deploy.outputs.details_url }}" >> $GITHUB_OUTPUT
echo "channel_id=${{ steps.get_preview_channel_id.outputs.preview_channel_id }}" >> $GITHUB_OUTPUT
else
echo "deployment_method=github_pages" >> $GITHUB_OUTPUT
echo "preview_url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/sdk-integration/${{ steps.get_preview_channel_id.outputs.preview_channel_id }}/" >> $GITHUB_OUTPUT
echo "channel_id=${{ steps.get_preview_channel_id.outputs.preview_channel_id }}" >> $GITHUB_OUTPUT
fi
- name: Display deployment information
shell: bash
run: |
echo "πŸš€ SDK Integration Preview deployed successfully!"
echo "πŸ“¦ SDK Branch: ${{ inputs.sdk_branch }}"
echo "πŸ”§ API Branch: ${{ inputs.api_branch }}"
echo "πŸͺ™ Coins Branch: ${{ inputs.coins_repo_branch }}"
echo "βš™οΈ Deployment Method Choice: ${{ inputs.deployment_method }}"
echo "πŸ—οΈ Actual Deployment Method: ${{ steps.deploy_result.outputs.deployment_method }}"
echo "πŸ†” Channel ID: ${{ steps.deploy_result.outputs.channel_id }}"
echo "🌐 Preview URL: ${{ steps.deploy_result.outputs.preview_url }}"
if [ "${{ steps.deploy_result.outputs.deployment_method }}" == "firebase" ]; then
echo "⏰ Preview expires in 7 days"
echo ""
echo "Your Firebase preview is available at:"
else
echo "πŸ“„ Deployed via GitHub Pages"
if [ "${{ inputs.deployment_method }}" == "github_pages" ]; then
echo "⚠️ WARNING: This deployment may have overwritten existing GitHub Pages content"
fi
echo ""
echo "Your GitHub Pages preview is available at:"
fi
echo "${{ steps.deploy_result.outputs.preview_url }}"
# Create GitHub Actions step summary for prominent display
echo "## πŸš€ SDK Integration Preview Deployed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Preview URL" >> $GITHUB_STEP_SUMMARY
echo "**[${{ steps.deploy_result.outputs.preview_url }}](${{ steps.deploy_result.outputs.preview_url }})**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Configuration" >> $GITHUB_STEP_SUMMARY
echo "- **API Branch:** \`${{ inputs.api_branch }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **SDK Branch:** \`${{ inputs.sdk_branch }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Coins Branch:** \`${{ inputs.coins_repo_branch }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Deployment Method Choice:** \`${{ inputs.deployment_method }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Actual Deployment Method:** \`${{ steps.deploy_result.outputs.deployment_method }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Channel ID:** \`${{ steps.deploy_result.outputs.channel_id }}\`" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.deploy_result.outputs.deployment_method }}" == "firebase" ]; then
echo "- **Expiration:** 7 days" >> $GITHUB_STEP_SUMMARY
else
echo "- **Hosting:** GitHub Pages" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.deployment_method }}" == "github_pages" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ **WARNING:** This deployment used GitHub Pages and may have overwritten existing content." >> $GITHUB_STEP_SUMMARY
fi
fi
# Add a notice annotation for the URL
echo "::notice title=🌐 Preview Deployed::Preview URL: ${{ steps.deploy_result.outputs.preview_url }}"