Branch and pull request previews are automatically deployed to subdirectories.
-
Each branch is accessible at /branch-name/
-
-
-
-
âšī¸ About
-
SGEX is an experimental collaborative project developing a workbench of tools to make it easier and faster to develop high fidelity SMART Guidelines Digital Adaptation Kits (DAKs).
-
-
-
-
-EOF
- fi
+ # Build the React app
+ npm run build
- # Verify index.html exists
+ # Verify build output exists
if [[ ! -f "build/index.html" ]]; then
- echo "ERROR: index.html not found in build output"
+ echo "ERROR: React build failed - index.html not found in build output"
exit 1
fi
- echo "â Landing page build completed"
+ echo "â React landing page build completed successfully"
+ echo "Build contents:"
+ ls -la build/
- name: Deploy to gh-pages root (preserving existing branches)
shell: bash
run: |
set -e
- # Save the landing page build
- echo "Preserving landing page build..."
+ # Save the React app build
+ echo "Preserving React app build..."
mkdir -p /tmp/landing-build
cp -a build/. /tmp/landing-build/
@@ -165,7 +121,7 @@ EOF
fi
# Deploy landing page to root (this will not affect any subdirectories)
- echo "Deploying landing page to root..."
+ echo "Deploying React app to root..."
cp -a /tmp/landing-build/. .
# Verify existing directories are still there
@@ -175,7 +131,7 @@ EOF
# Clean up temporary build
rm -rf /tmp/landing-build
- echo "â Landing page deployed to gh-pages root while preserving all branch directories"
+ echo "â React app deployed to gh-pages root while preserving all branch directories"
- name: Commit and push changes
shell: bash
@@ -207,9 +163,9 @@ EOF
trigger_info="Auto-triggered by push to main"
fi
- git commit -m "đ Deploy landing page (${deployment_type})
+ git commit -m "đ Deploy React landing page (${deployment_type})
- - Updated landing page with self-contained assets from deploy branch
+ - Updated with React app build from main branch
- ${trigger_info}
- Deployed at $(date -u '+%Y-%m-%d %H:%M:%S UTC')
- Commit: ${{ github.sha }}"
@@ -218,7 +174,7 @@ EOF
git pull origin gh-pages --rebase || echo "Pull failed, attempting to push anyway..."
git push origin gh-pages
- echo "â Landing page deployment completed successfully"
+ echo "â React landing page deployment completed successfully"
fi
- name: Output deployment info
@@ -235,7 +191,7 @@ EOF
trigger_info="Auto-triggered by push to main"
fi
- echo "đ Landing Page Deployment Summary:"
+ echo "đ React Landing Page Deployment Summary:"
echo "- Landing Page URL: $landing_url"
echo "- Deployment Type: $deployment_type"
echo "- $trigger_info"
From e4befd105afcb2ebbc898be85267d0d8e8e2843e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 5 Aug 2025 13:44:00 +0000
Subject: [PATCH 3/3] Create branch deployment selector React app on deploy
branch
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
---
.github/workflows/deploy-branch-selector.yml | 262 ++++++++++++++++
package.json | 2 +-
src/App.js | 93 +-----
src/components/BranchDeploymentSelector.css | 303 +++++++++++++++++++
src/components/BranchDeploymentSelector.js | 194 ++++++++++++
5 files changed, 765 insertions(+), 89 deletions(-)
create mode 100644 .github/workflows/deploy-branch-selector.yml
create mode 100644 src/components/BranchDeploymentSelector.css
create mode 100644 src/components/BranchDeploymentSelector.js
diff --git a/.github/workflows/deploy-branch-selector.yml b/.github/workflows/deploy-branch-selector.yml
new file mode 100644
index 000000000..79817bfb5
--- /dev/null
+++ b/.github/workflows/deploy-branch-selector.yml
@@ -0,0 +1,262 @@
+name: Deploy Branch Selector
+
+on:
+ pull_request:
+ branches:
+ - deploy
+ types: [opened, synchronize, reopened]
+ workflow_dispatch:
+ inputs:
+ pr_number:
+ description: 'PR number to deploy (optional - will auto-detect if running from PR)'
+ required: false
+ type: string
+
+permissions:
+ contents: write
+ pages: write
+ id-token: write
+ pull-requests: write
+
+concurrency:
+ group: "deploy-branch-selector-${{ github.event.pull_request.number || github.event.inputs.pr_number || 'manual' }}"
+ cancel-in-progress: true
+
+jobs:
+ deploy-branch-selector:
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+
+ steps:
+ - name: Get PR information
+ id: pr_info
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
+ PR_NUMBER="${{ github.event.pull_request.number }}"
+ HEAD_SHA="${{ github.event.pull_request.head.sha }}"
+ HEAD_REF="${{ github.event.pull_request.head.ref }}"
+ elif [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.pr_number }}" ]]; then
+ PR_NUMBER="${{ github.event.inputs.pr_number }}"
+ # We'll need to fetch PR details via API
+ HEAD_SHA="${{ github.sha }}"
+ HEAD_REF="${{ github.ref_name }}"
+ else
+ echo "ERROR: This workflow should only run on PRs or with PR number input"
+ exit 1
+ fi
+
+ echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
+ echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_OUTPUT
+ echo "HEAD_REF=$HEAD_REF" >> $GITHUB_OUTPUT
+
+ echo "Deploying PR #$PR_NUMBER (SHA: $HEAD_SHA, Ref: $HEAD_REF)"
+
+ - name: Checkout PR head
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ steps.pr_info.outputs.HEAD_SHA }}
+ fetch-depth: 0
+
+ - name: Configure git user
+ shell: bash
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: 'npm'
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Build branch deployment selector
+ shell: bash
+ run: |
+ set -e
+
+ echo "Building branch deployment selector React app..."
+
+ # Build the React app
+ npm run build
+
+ # Verify build output exists
+ if [[ ! -f "build/index.html" ]]; then
+ echo "ERROR: React build failed - index.html not found in build output"
+ exit 1
+ fi
+
+ echo "â Branch deployment selector build completed successfully"
+ echo "Build contents:"
+ ls -la build/
+
+ - name: Deploy to gh-pages root (preserving existing branches)
+ shell: bash
+ run: |
+ set -e
+
+ # Save the React app build
+ echo "Preserving React app build..."
+ mkdir -p /tmp/selector-build
+ cp -a build/. /tmp/selector-build/
+
+ # Checkout gh-pages branch
+ if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
+ echo "Checking out existing gh-pages branch"
+ git stash -u -m "Stash before gh-pages checkout" || echo "Nothing to stash"
+ git clean -fd -e node_modules
+ git checkout gh-pages
+ else
+ echo "Creating new gh-pages branch"
+ git checkout --orphan gh-pages
+ git rm -rf .
+ echo "# GitHub Pages" > README.md
+ git add README.md
+ git commit -m "Initial gh-pages branch"
+ git push origin gh-pages
+ fi
+
+ # CRITICAL: Only remove files, NEVER remove directories (to preserve branch builds)
+ echo "Removing only root-level files (preserving all branch directories)..."
+
+ # List what directories exist for safety verification
+ echo "Existing directories before cleanup:"
+ ls -la */ 2>/dev/null || echo "No directories found"
+
+ # Remove only specific files that could conflict with deployment selector
+ rm -f index.html
+ rm -f manifest.json
+ rm -f asset-manifest.json
+ rm -f service-worker.js
+ rm -f robots.txt
+ rm -f favicon.ico
+ rm -f logo*.png
+ rm -f README.md
+ rm -f package.json
+ rm -f package-lock.json
+
+ # Remove static directory only if it exists at root (not in branch subdirs)
+ if [[ -d "static" ]]; then
+ echo "Removing root static directory..."
+ rm -rf static
+ fi
+
+ # Deploy deployment selector to root
+ echo "Deploying branch deployment selector to root..."
+ cp -a /tmp/selector-build/. .
+
+ # Verify existing directories are still there
+ echo "Directories after deployment:"
+ ls -la */ 2>/dev/null || echo "No directories found"
+
+ # Clean up temporary build
+ rm -rf /tmp/selector-build
+
+ echo "â Branch deployment selector deployed to gh-pages root while preserving all branch directories"
+
+ - name: Commit and push changes
+ shell: bash
+ run: |
+ set -e
+
+ # Verify we're on gh-pages branch
+ current_branch=$(git branch --show-current)
+ if [[ "$current_branch" != "gh-pages" ]]; then
+ echo "ERROR: Not on gh-pages branch! Current branch: $current_branch"
+ exit 1
+ fi
+
+ # Stage all changes
+ git add -A
+
+ # Check if there are changes to commit
+ if git diff --cached --quiet; then
+ echo "No changes to commit"
+ else
+ echo "Committing branch deployment selector..."
+
+ git commit -m "đ Deploy branch deployment selector from PR #${{ steps.pr_info.outputs.PR_NUMBER }}
+
+ - Updated deployment selector from deploy branch PR
+ - Built from commit ${{ steps.pr_info.outputs.HEAD_SHA }}
+ - Deployed at $(date -u '+%Y-%m-%d %H:%M:%S UTC')
+ - Preserves all existing feature branch deployments"
+
+ echo "Pushing to gh-pages..."
+ git pull origin gh-pages --rebase || echo "Pull failed, attempting to push anyway..."
+ git push origin gh-pages
+
+ echo "â Branch deployment selector deployment completed successfully"
+ fi
+
+ - name: Output deployment info
+ id: deployment
+ shell: bash
+ run: |
+ deployment_url="https://litlfred.github.io/sgex/"
+
+ echo "đ Branch Deployment Selector Summary:"
+ echo "- Deployment URL: $deployment_url"
+ echo "- PR Number: #${{ steps.pr_info.outputs.PR_NUMBER }}"
+ echo "- Source Branch: ${{ steps.pr_info.outputs.HEAD_REF }}"
+ echo "- Commit: ${{ steps.pr_info.outputs.HEAD_SHA }}"
+ echo "- Deployed at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
+
+ echo "page_url=$deployment_url" >> $GITHUB_OUTPUT
+
+ - name: Comment on PR
+ if: github.event_name == 'pull_request'
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const { data: comments } = await github.rest.issues.listComments({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ });
+
+ const botComment = comments.find(comment =>
+ comment.user.type === 'Bot' &&
+ comment.body.includes('đ Branch Deployment Selector')
+ );
+
+ const deploymentUrl = "https://litlfred.github.io/sgex/";
+ const commitSha = "${{ steps.pr_info.outputs.HEAD_SHA }}";
+ const shortSha = commitSha.substring(0, 7);
+
+ const commentBody = `đ **Branch Deployment Selector Deployed**
+
+ The branch deployment selector has been successfully deployed from this PR.
+
+ đ **View Deployment**: ${deploymentUrl}
+
+ đ **Deployment Details**:
+ - **Source**: \`${{ steps.pr_info.outputs.HEAD_REF }}\` branch
+ - **Commit**: \`${shortSha}\`
+ - **Deployed**: ${new Date().toISOString().replace('T', ' ').substring(0, 19)} UTC
+
+ âšī¸ **Note**: This deployment replaces the root page of the site but preserves all existing feature branch deployments in their subdirectories.
+
+ ---
+ *Deployment will update automatically when new commits are pushed to this PR.*`;
+
+ if (botComment) {
+ await github.rest.issues.updateComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ comment_id: botComment.id,
+ body: commentBody
+ });
+ } else {
+ await github.rest.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ body: commentBody
+ });
+ }
\ No newline at end of file
diff --git a/package.json b/package.json
index 3ffe2f430..4de05f6ac 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "SGEX Workbench - WHO SMART Guidelines Exchange collaborative editor",
"private": true,
- "homepage": "/sgex/",
+ "homepage": "/",
"dependencies": {
"@octokit/rest": "^22.0.0",
"@testing-library/jest-dom": "^6.6.4",
diff --git a/src/App.js b/src/App.js
index bbc21000e..3a70635b6 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,44 +1,20 @@
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import './i18n'; // Initialize i18n
-import WelcomePage from './components/WelcomePage';
-import SelectProfilePage from './components/SelectProfilePage';
-import DAKActionSelection from './components/DAKActionSelection';
-import DAKSelection from './components/DAKSelection';
-import OrganizationSelection from './components/OrganizationSelection';
-import DAKConfiguration from './components/DAKConfiguration';
-
-import ComponentEditor from './components/ComponentEditor';
-import CoreDataDictionaryViewer from './components/CoreDataDictionaryViewer';
-import ActorEditor from './components/ActorEditor';
-import BPMNEditor from './components/BPMNEditor';
-import BusinessProcessSelection from './components/BusinessProcessSelection';
-import BPMNViewer from './components/BPMNViewer';
-import BPMNSource from './components/BPMNSource';
-import BPMNViewerTestComponent from './components/BPMNViewerTestComponent';
-import DocumentationViewer from './components/DocumentationViewer';
-import DecisionSupportLogicView from './components/DecisionSupportLogicView';
-import TestDashboard from './components/TestDashboard';
-import TestingViewer from './components/TestingViewer';
-import PagesManager from './components/PagesManager';
+import BranchDeploymentSelector from './components/BranchDeploymentSelector';
import NotFound from './components/NotFound';
-import LandingPageWithFramework from './components/LandingPageWithFramework';
-import DAKDashboardWithFramework from './components/DAKDashboardWithFramework';
-import DashboardRedirect from './components/DashboardRedirect';
-import TestDocumentationPage from './components/TestDocumentationPage';
-import AssetEditorTest from './components/AssetEditorTest';
import logger from './utils/logger';
import './App.css';
function App() {
const appLogger = logger.getLogger('App');
- // Get basename from PUBLIC_URL or default to /sgex, but use empty in development if no PUBLIC_URL
- const basename = process.env.PUBLIC_URL || (process.env.NODE_ENV === 'development' ? '' : '/sgex');
+ // Get basename from PUBLIC_URL or default to empty for deployment selector
+ const basename = process.env.PUBLIC_URL || '';
React.useEffect(() => {
appLogger.componentMount();
- appLogger.info('SGEX Workbench application started', {
+ appLogger.info('SGEX Branch Deployment Selector started', {
environment: process.env.NODE_ENV,
basename: basename
});
@@ -52,66 +28,7 @@ function App() {
+ Select a deployment to explore different versions and features of SGEX Workbench.
+ Each deployment represents a different branch or feature in development.
+
+ Each deployment represents a different version of SGEX Workbench. The main deployment
+ contains the stable, production-ready version. Feature deployments contain experimental
+ features and improvements that are being tested before they are merged into the main application.
+
+
+ Feature deployments may contain incomplete features or bugs. Use them to preview upcoming
+ functionality and provide feedback to the development team.
+
+
+
+
+
+ );
+};
+
+export default BranchDeploymentSelector;
\ No newline at end of file