From c0a747900c45912f4666fd53000c646c6b97f994 Mon Sep 17 00:00:00 2001 From: Van Allen Diongzon Date: Thu, 3 Apr 2025 06:12:09 +0800 Subject: [PATCH 1/6] [Adjustment][Van] Add FORK.md and Context.md --- FORK.md | 90 ++++++++++++++++++++++++++++++++++ api/Context.md | 129 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 FORK.md create mode 100644 api/Context.md diff --git a/FORK.md b/FORK.md new file mode 100644 index 000000000..a3326ecd6 --- /dev/null +++ b/FORK.md @@ -0,0 +1,90 @@ +# Maintaining Your Code-Push-Server Fork + +This document outlines the process for keeping your fork of the code-push-server repository in sync with the official Microsoft repository. + +## Initial Setup (Do Once) + +1. **Fork the repository** + + - Go to https://github.com/microsoft/code-push-server + - Click the "Fork" button in the top-right corner + - This creates a copy of the repository under your GitHub account + +2. **Clone your fork to your local machine** + + ``` + git clone https://github.com/YOUR-USERNAME/code-push-server.git + ``` + + - This downloads your fork to your computer + - Replace `YOUR-USERNAME` with your GitHub username + +3. **Navigate to the repository directory** + + ``` + cd code-push-server + ``` + +4. **Add the original repository as an "upstream" remote** + + ``` + git remote add upstream https://github.com/microsoft/code-push-server.git + ``` + + - `remote add`: Adds a new remote repository reference + - `upstream`: Common name used for the original repository + - The URL points to the original Microsoft repository + +5. **Verify the remotes are set up correctly** + ``` + git remote -v + ``` + - Should show both `origin` (your fork) and `upstream` (original repo) + +## Updating Your Fork (Do Periodically) + +1. **Fetch all changes from the upstream repository** + + ``` + git fetch upstream + ``` + + - Downloads all changes from the original repository without merging them + +2. **Switch to your main branch** + + ``` + git checkout main + ``` + + - Ensures you're on your main branch to receive the updates + +3. **Merge the changes from upstream's main branch** + + ``` + git merge upstream/main + ``` + + - Integrates the original repository's changes into your local copy + +4. **Push the updated main branch to your fork** + ``` + git push origin main + ``` + - Uploads the updated branch to your GitHub fork + +## Working with Your Fork + +- If you want to make your own changes, create a new branch from the updated main: + + ``` + git checkout -b your-feature-branch + ``` + +- After making changes, push your feature branch to GitHub: + + ``` + git push origin your-feature-branch + ``` + +- Always update your main branch from upstream before creating new feature branches to ensure you're working with the latest code. diff --git a/api/Context.md b/api/Context.md new file mode 100644 index 000000000..5b89f4b00 --- /dev/null +++ b/api/Context.md @@ -0,0 +1,129 @@ +# CodePush Server Azure Deployment Context + +## Project Overview + +- **Repository**: https://github.com/symphco/ml-code-push-server.git +- **Environments**: + - Development (codepush-devml) + - Production (pending deployment) + +## Infrastructure Architecture + +- **Azure Structure**: + - Single subscription with multiple resource groups + - Separate resource groups for dev and prod environments + - Each environment contains App Service, App Service Plan, and Storage Account + +## Deployment Status + +### Completed Actions + +- Created resource groups: + + ```bash + az group create --name codepush-dev-rg --location eastus + az group create --name codepush-prod-rg --location eastus + ``` + +- Deployed infrastructure with bicep: + + ```bash + az deployment group create --resource-group codepush-dev-rg --template-file ./codepush-infrastructure.bicep --parameters project_suffix=devml az_location=eastus microsoft_client_id= microsoft_client_secret= + ``` + +- Setup Microsoft OAuth applications in Azure AD with redirect URIs: + + - Dev: `https://codepush-devml.azurewebsites.net/auth/callback/microsoft` and `https://codepush-devml.azurewebsites.net/auth/callback/azure-ad` + - Prod: Equivalent URLs with prod suffix + +- Configured Git deployment: + + ```bash + # Add GitHub authentication token + az webapp deployment source update-token --git-token --token-type github + + # Configure deployment source + az webapp deployment source config --resource-group codepush-dev-rg --name codepush-devml --repo-url https://github.com/symphco/ml-code-push-server.git --branch main + + # Set project folder location + az webapp config appsettings set --resource-group codepush-dev-rg --name codepush-devml --settings PROJECT=api + ``` + +### Resources Created + +- Dev Environment: + - Resource Group: codepush-dev-rg + - App Service: codepush-devml + - Storage Account: with unique name based on project suffix + +## Technical Requirements & Constraints + +### Azure Naming Limitations + +- Project suffix: + - Only letters allowed (no numbers or special characters) + - Maximum 15 characters +- Storage account names must be globally unique across all Azure + +### Authentication + +- Using Microsoft OAuth (work and personal accounts) +- GitHub authentication is optional alternative + +### Environment Variables + +- Set directly in Azure App Service Configuration +- No need for local `.env` file + +### Git Repository Access + +- Only HTTPS URLs supported (not SSH) +- Private repositories require GitHub Personal Access Token with "repo" scope + +## Common Issues & Solutions + +1. **Storage Account Name Conflicts**: + + - Error: "The storage account named codepushstorageXXX is already taken" + - Solution: Use more unique suffix + +2. **GitHub Authentication Issues**: + + - Error: "Cannot find SourceControlToken with name GitHub" + - Solution: Add GitHub PAT token using `az webapp deployment source update-token` + +3. **Git URL Format**: + - Problem: SSH format not supported + - Solution: Use HTTPS format for GitHub repositories + +## Client Integration + +### Android Configuration + +Add to `strings.xml`: + +```xml +https://codepush-devml.azurewebsites.net +``` + +### iOS Configuration + +Add to `Info.plist`: + +```xml +CodePushServerURL +https://codepush-devml.azurewebsites.net +``` + +## Monitoring & Management + +- Deployment status: Azure Portal > App Service > Deployment Center +- Manual deployment: Use "Sync" button in Deployment Center +- Environment variables: Azure Portal > App Service > Configuration > Application settings + +## Next Steps + +1. Verify dev deployment is working correctly +2. Complete production environment deployment if needed +3. Test client integration with mobile apps +4. Establish CI/CD workflow for ongoing development From f2ad16f76582d456e202082269df9c0034bf70d0 Mon Sep 17 00:00:00 2001 From: Raven <631312+coderaven@users.noreply.github.com> Date: Thu, 3 Apr 2025 12:22:28 +0800 Subject: [PATCH 2/6] Add or update the Azure App Service build and deployment workflow config --- .../workflows/development_codepush-devml.yml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/development_codepush-devml.yml diff --git a/.github/workflows/development_codepush-devml.yml b/.github/workflows/development_codepush-devml.yml new file mode 100644 index 000000000..80cee84d8 --- /dev/null +++ b/.github/workflows/development_codepush-devml.yml @@ -0,0 +1,64 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy Node.js app to Azure Web App - codepush-devml + +on: + push: + branches: + - development + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js version + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm run test --if-present + + - name: Zip artifact for deployment + run: zip release.zip ./* -r + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: node-app + path: release.zip + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: node-app + + - name: Unzip artifact for deployment + run: unzip release.zip + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: 'codepush-devml' + slot-name: 'Production' + package: . + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_24983D3EF8324CB0860C6EDAAC13D1DE }} \ No newline at end of file From 072e9b6f724ca3d33affb6e1970f0044a29847ac Mon Sep 17 00:00:00 2001 From: Van Allen Diongzon Date: Mon, 14 Apr 2025 19:14:49 +0800 Subject: [PATCH 3/6] [Adjustment][Van] Add working directory --- .../workflows/development_codepush-devml.yml | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/development_codepush-devml.yml b/.github/workflows/development_codepush-devml.yml index 80cee84d8..591c95649 100644 --- a/.github/workflows/development_codepush-devml.yml +++ b/.github/workflows/development_codepush-devml.yml @@ -21,16 +21,19 @@ jobs: - name: Set up Node.js version uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: "18.x" - name: npm install, build, and test + working-directory: ./api run: | npm install npm run build --if-present npm run test --if-present - name: Zip artifact for deployment - run: zip release.zip ./* -r + run: | + cd api + zip -r ../release.zip ./* - name: Upload artifact for deployment job uses: actions/upload-artifact@v4 @@ -41,10 +44,10 @@ jobs: deploy: runs-on: ubuntu-latest needs: build - environment: - name: 'Production' + environment: + name: "Production" url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - + steps: - name: Download artifact from build job uses: actions/download-artifact@v4 @@ -53,12 +56,12 @@ jobs: - name: Unzip artifact for deployment run: unzip release.zip - - - name: 'Deploy to Azure Web App' + + - name: "Deploy to Azure Web App" id: deploy-to-webapp uses: azure/webapps-deploy@v3 with: - app-name: 'codepush-devml' - slot-name: 'Production' + app-name: "codepush-devml" + slot-name: "Production" package: . - publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_24983D3EF8324CB0860C6EDAAC13D1DE }} \ No newline at end of file + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_24983D3EF8324CB0860C6EDAAC13D1DE }} From c75d85cb8b571dd7a670ea26cb375aabb009bf28 Mon Sep 17 00:00:00 2001 From: Van Allen Diongzon Date: Mon, 14 Apr 2025 19:59:41 +0800 Subject: [PATCH 4/6] [Adjustment][Van] Add github action for prod --- .../workflows/production_codepush-prodml.yml | 67 +++ FRIENDLY_DOCS.md | 383 ++++++++++++++++++ 2 files changed, 450 insertions(+) create mode 100644 .github/workflows/production_codepush-prodml.yml create mode 100644 FRIENDLY_DOCS.md diff --git a/.github/workflows/production_codepush-prodml.yml b/.github/workflows/production_codepush-prodml.yml new file mode 100644 index 000000000..e5333429e --- /dev/null +++ b/.github/workflows/production_codepush-prodml.yml @@ -0,0 +1,67 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy Node.js app to Azure Web App - codepush-prodml + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js version + uses: actions/setup-node@v3 + with: + node-version: "18.x" + + - name: npm install, build, and test + working-directory: ./api + run: | + npm install + npm run build --if-present + npm run test --if-present + + - name: Zip artifact for deployment + run: | + cd api + zip -r ../release.zip ./* + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: node-app + path: release.zip + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: "Production" + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: node-app + + - name: Unzip artifact for deployment + run: unzip release.zip + + - name: "Deploy to Azure Web App" + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: "codepush-prodml" + slot-name: "Production" + package: . + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_PRODUCTION }} diff --git a/FRIENDLY_DOCS.md b/FRIENDLY_DOCS.md new file mode 100644 index 000000000..beae4112e --- /dev/null +++ b/FRIENDLY_DOCS.md @@ -0,0 +1,383 @@ +# Setting Up and Deploying CodePush Server to Azure: A Beginner's Guide + +This guide will walk you through the entire process of setting up the CodePush Server locally and deploying it to Azure, explaining how all the configuration files work together. + +## Table of Contents + +1. [What is CodePush?](#what-is-codepush) +2. [Repository Structure Overview](#repository-structure-overview) +3. [Setting Up Locally](#setting-up-locally) +4. [Deploying to Azure](#deploying-to-azure) +5. [GitHub Actions Workflows](#github-actions-workflows) +6. [Authentication with OAuth Apps](#authentication-with-oauth-apps) +7. [Security Considerations](#security-considerations) +8. [Metrics](#metrics) +9. [Troubleshooting](#troubleshooting) +10. [Configuring React Native Apps to Use Your Server](#configuring-react-native-apps-to-use-your-server) +11. [Quick Start: Step by Step Commands](#quick-start-step-by-step-commands) + +## What is CodePush? + +CodePush is a service that allows React Native developers to deploy mobile app updates directly to users' devices without going through the app store review process. The CodePush Server is the backend service that powers this functionality, allowing you to host your own CodePush service. + +## Repository Structure Overview + +The key files we'll be working with include: + +- **codepush-infrastructure.bicep**: Defines the Azure infrastructure needed for deployment +- **README.md**: Contains basic setup instructions +- **.github/workflows/development_codepush-devml.yml**: GitHub Actions workflow for automatic deployment +- **.github/workflows/codeql.yml**: GitHub Actions workflow for code security scanning +- **.env.example**: Template for environment variables + +## Setting Up Locally + +### Prerequisites + +1. **Node.js**: Make sure you have Node.js 18 LTS installed +2. **Azure CLI**: Install the Azure Command-Line Interface +3. **Azurite**: For local Azure Storage emulation +4. **OAuth Apps**: You'll need GitHub and/or Microsoft OAuth applications for user authentication + +### Step 1: Clone the Repository + +```bash +git clone +cd ml-code-push-server +``` + +### Step 2: Set Up Environment Variables + +```bash +cd api +cp .env.example .env +``` + +Now edit the `.env` file to set your environment variables. For local development, make sure to set: + +- `EMULATED=true` (to use Azurite instead of real Azure Storage) +- OAuth credentials for authentication (GitHub/Microsoft) + +### Step 3: Install Dependencies + +```bash +npm install +``` + +### Step 4: Start Azurite + +Follow the Azurite [installation instructions](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite) and start it: + +```bash +# Example using npm +npm install -g azurite +azurite --silent --location azurite --debug azurite/debug.log +``` + +### Step 5: Build and Run the Server + +```bash +npm run build +npm run start:env +``` + +By default, the server runs on HTTP (localhost:3000). For HTTPS: + +1. Create a `certs` directory with `cert.key` and `cert.crt` files +2. Set `HTTPS=true` in your `.env` file +3. The server will run on localhost:8443 + +## Authentication with OAuth Apps + +### Why OAuth Apps are Required for CodePush + +OAuth Apps are **essential** for your CodePush server deployment because: + +1. **User Authentication**: They provide the authentication system for your CodePush server, allowing users to log in with existing GitHub or Microsoft accounts. + +2. **Access Control**: They determine who can access your CodePush server to deploy updates to mobile applications. + +3. **Security**: They eliminate the need to build your own authentication system or store user credentials. + +4. **Deployment Management**: They control who has permission to create and manage deployments for different applications. + +Without at least one OAuth provider configured, your CodePush server would have no way to authenticate users, making it impossible to use the system for deploying updates. + +### Setting Up a GitHub OAuth App + +1. Go to https://github.com/settings/developers +2. Click "New OAuth App" +3. Fill in required details: + - Application name: "CodePush Server" (or any name you prefer) + - Homepage URL: Your CodePush server URL (e.g., `https://codepush-YOUR-SUFFIX.azurewebsites.net` or `http://localhost:3000` for local) + - Authorization callback URL: `{server-url}/auth/callback/github` (this must be exact) +4. Click "Register application" to get your Client ID +5. Generate a new Client Secret +6. Save both values for your CodePush server configuration + +### Setting Up a Microsoft OAuth App + +1. Register an app at https://portal.azure.com → Azure Active Directory → App registrations → New registration +2. Name your application (e.g., "CodePush Server") +3. Choose the account type based on your needs: + - For both personal and work accounts: "Accounts in any organizational directory and personal Microsoft accounts" + - For work accounts only: Select appropriate tenant option + - For personal accounts only: "Personal Microsoft accounts only" +4. Set redirect URIs: + - For personal accounts: `{server-url}/auth/callback/microsoft` + - For work accounts: `{server-url}/auth/callback/azure-ad` +5. After registration, copy the Application (client) ID +6. Create a client secret: Certificates & secrets → New client secret +7. Copy and save both values for your CodePush server configuration + +### Adding OAuth Credentials to Your CodePush Server + +#### For Local Development: + +Add to your `.env` file: + +``` +# GitHub OAuth +GITHUB_CLIENT_ID=your_github_client_id +GITHUB_CLIENT_SECRET=your_github_client_secret + +# Microsoft OAuth +MICROSOFT_CLIENT_ID=your_microsoft_client_id +MICROSOFT_CLIENT_SECRET=your_microsoft_client_secret +# Only needed for single tenant work account setup +MICROSOFT_TENANT_ID=your_tenant_id +``` + +#### For Azure Deployment: + +Include these parameters when running the bicep deployment or add them in the Azure Portal under your Web App → Configuration → Application settings. + +## Deploying to Azure + +### Step 1: Login to Azure + +```bash +az login +az account set --subscription +``` + +### Step 2: Create a Resource Group + +```bash +az group create --name --location eastus +``` + +### Step 3: Understanding the Bicep Template + +The `codepush-infrastructure.bicep` file defines all the resources needed to run CodePush: + +- **App Service Plan**: Hosts your application (named: codepush-asp-{suffix}) +- **Storage Account**: Stores your CodePush packages (named: codepushstorage{suffix}) +- **Web App**: The actual CodePush server (named: codepush-{suffix}) + +Important parameters: + +- `project_suffix`: Used in naming all resources (letters only, max 15 chars) +- `az_location`: Azure region (default: eastus) +- OAuth credentials for GitHub and Microsoft authentication +- `logging`: Boolean parameter to enable/disable logging (default: true) + +### Step 4: Deploy the Infrastructure + +```bash +az deployment group create \ + --resource-group \ + --template-file ./codepush-infrastructure.bicep \ + --parameters project_suffix= \ + az_location=eastus \ + github_client_id= \ + github_client_secret= \ + microsoft_client_id= \ + microsoft_client_secret= +``` + +Notes: + +- Choose a unique suffix (letters only, max 15 chars) +- OAuth parameters are optional but recommended for authentication +- **Important**: At least one OAuth provider (GitHub or Microsoft) must be configured for the system to work properly +- If using Microsoft single tenant work accounts, you'll need to add the `MICROSOFT_TENANT_ID` parameter after deployment +- Your server URL will be: https://codepush-{suffix}.azurewebsites.net + +### Step 5: Manual Deployment to Azure Web App + +After creating the infrastructure, you can deploy your application manually: + +1. Build your application: `npm run build` +2. Zip the contents: `zip -r release.zip ./*` +3. Deploy using the Azure CLI: + +```bash +az webapp deployment source config-zip --resource-group --name codepush- --src release.zip +``` + +## GitHub Actions Workflows + +You can set up GitHub Actions workflows for automated deployment and security scanning of your CodePush server: + +### Automated Deployment + +A deployment workflow can automatically deploy your CodePush server to Azure when changes are pushed to your repository: + +1. **Typical Components**: + - Triggers on pushes to a specific branch or manual workflow dispatch + - Build job that checks out code, sets up Node.js, installs dependencies, builds, and tests + - Deploy job that deploys built artifacts to Azure Web App + +To set up automated deployment: + +1. Create a workflow file in `.github/workflows/` directory of your repository +2. Create an Azure Web App publish profile +3. Add the publish profile as a GitHub secret +4. Configure the workflow to use your Azure Web App name and resource group + +### Security Scanning + +You can also set up a security scanning workflow that performs analysis on your codebase: + +1. **Typical Components**: + - Runs on pushes to main branch, pull requests, or on a schedule + - Sets up and runs code analysis tools like CodeQL + - Reports security findings + +These workflows will help automate your deployment process and ensure code security. + +## Security Considerations + +1. The default Azure Blob Storage is accessible to all subscription users - consider adjusting access settings +2. Always use HTTPS in production (enabled by default on Azure App Service) +3. Protect your OAuth credentials +4. Run security scans regularly to check for vulnerabilities + +## Metrics + +If you want to monitor release activity via the CLI: + +1. Redis is required for metrics functionality +2. Follow the [official Redis installation guide](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) +3. TLS is required for Redis - follow the [official Redis TLS setup guide](https://redis.io/docs/latest/operate/oss_and_stack/management/security/encryption/#running-manually) +4. Set the necessary environment variables for Redis in your configuration + +## Troubleshooting + +### Common Issues: + +1. **Deployment Fails**: Check that your project suffix meets naming requirements (letters only, max 15 chars) +2. **Authentication Issues**: Verify OAuth callback URLs match your server URL exactly +3. **Storage Errors**: Ensure Azurite is running for local development, or check storage account access keys +4. **Node.js Version**: Make sure you're using Node.js 18 LTS as specified + +For more detailed troubleshooting, check the logs in your Azure Web App or local development environment. + +## Configuring React Native Apps to Use Your Server + +To make your React Native apps use your CodePush server: + +### Android + +In `strings.xml`, add: + +```xml +https://codepush-YOUR-SUFFIX.azurewebsites.net +``` + +### iOS + +In `Info.plist`, add: + +```xml +CodePushServerURL +https://codepush-YOUR-SUFFIX.azurewebsites.net +``` + +## Quick Start: Step by Step Commands + +Here's a complete step-by-step command guide to set up and deploy CodePush Server: + +### Local Development Setup + +```bash +# 1. Clone the repository +git clone +cd ml-code-push-server + +# 2. Navigate to the API directory +cd api + +# 3. Set up environment variables +cp .env.example .env + +# 4. Install dependencies +npm install + +# 5. Install Azurite for local storage emulation +npm install -g azurite + +# 6. Start Azurite in a separate terminal +azurite --silent --location azurite --debug azurite/debug.log + +# 7. Build the CodePush server +npm run build + +# 8. Start the server with environment variables +npm run start:env +``` + +### Azure Deployment + +```bash +# 1. Login to Azure +az login + +# 2. Set your subscription +az account set --subscription "" + +# 3. Create a resource group +az group create --name "codepush-rg" --location "eastus" + +# 4. Deploy the infrastructure +az deployment group create \ + --resource-group "codepush-rg" \ + --template-file ./codepush-infrastructure.bicep \ + --parameters project_suffix="" \ + az_location="eastus" \ + github_client_id="" \ + github_client_secret="" \ + microsoft_client_id="" \ + microsoft_client_secret="" + +# 5. Build the application for deployment +npm run build + +# 6. Create a deployment package +zip -r release.zip ./* + +# 7. Deploy the package to the Azure Web App +az webapp deployment source config-zip \ + --resource-group "codepush-rg" \ + --name "codepush-" \ + --src release.zip +``` + +### Using the CLI with Your CodePush Server + +```bash +# Install the CodePush CLI +npm install -g code-push-cli + +# Login to your CodePush server +code-push login --serverUrl https://codepush-.azurewebsites.net + +# Register your app +code-push app add + +# Deploy an update +code-push release-react --development +``` + +Remember to replace placeholder values (``, ``, etc.) with your actual values. Also, make sure you have set up at least one OAuth provider (GitHub or Microsoft) before deployment. From 0ce919dc3a5e660b7c38db4cdc48a06ca4af1886 Mon Sep 17 00:00:00 2001 From: Van Allen Diongzon Date: Mon, 14 Apr 2025 20:01:32 +0800 Subject: [PATCH 5/6] [Adjustment][Van] Remove context.md --- api/Context.md | 129 ------------------------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 api/Context.md diff --git a/api/Context.md b/api/Context.md deleted file mode 100644 index 5b89f4b00..000000000 --- a/api/Context.md +++ /dev/null @@ -1,129 +0,0 @@ -# CodePush Server Azure Deployment Context - -## Project Overview - -- **Repository**: https://github.com/symphco/ml-code-push-server.git -- **Environments**: - - Development (codepush-devml) - - Production (pending deployment) - -## Infrastructure Architecture - -- **Azure Structure**: - - Single subscription with multiple resource groups - - Separate resource groups for dev and prod environments - - Each environment contains App Service, App Service Plan, and Storage Account - -## Deployment Status - -### Completed Actions - -- Created resource groups: - - ```bash - az group create --name codepush-dev-rg --location eastus - az group create --name codepush-prod-rg --location eastus - ``` - -- Deployed infrastructure with bicep: - - ```bash - az deployment group create --resource-group codepush-dev-rg --template-file ./codepush-infrastructure.bicep --parameters project_suffix=devml az_location=eastus microsoft_client_id= microsoft_client_secret= - ``` - -- Setup Microsoft OAuth applications in Azure AD with redirect URIs: - - - Dev: `https://codepush-devml.azurewebsites.net/auth/callback/microsoft` and `https://codepush-devml.azurewebsites.net/auth/callback/azure-ad` - - Prod: Equivalent URLs with prod suffix - -- Configured Git deployment: - - ```bash - # Add GitHub authentication token - az webapp deployment source update-token --git-token --token-type github - - # Configure deployment source - az webapp deployment source config --resource-group codepush-dev-rg --name codepush-devml --repo-url https://github.com/symphco/ml-code-push-server.git --branch main - - # Set project folder location - az webapp config appsettings set --resource-group codepush-dev-rg --name codepush-devml --settings PROJECT=api - ``` - -### Resources Created - -- Dev Environment: - - Resource Group: codepush-dev-rg - - App Service: codepush-devml - - Storage Account: with unique name based on project suffix - -## Technical Requirements & Constraints - -### Azure Naming Limitations - -- Project suffix: - - Only letters allowed (no numbers or special characters) - - Maximum 15 characters -- Storage account names must be globally unique across all Azure - -### Authentication - -- Using Microsoft OAuth (work and personal accounts) -- GitHub authentication is optional alternative - -### Environment Variables - -- Set directly in Azure App Service Configuration -- No need for local `.env` file - -### Git Repository Access - -- Only HTTPS URLs supported (not SSH) -- Private repositories require GitHub Personal Access Token with "repo" scope - -## Common Issues & Solutions - -1. **Storage Account Name Conflicts**: - - - Error: "The storage account named codepushstorageXXX is already taken" - - Solution: Use more unique suffix - -2. **GitHub Authentication Issues**: - - - Error: "Cannot find SourceControlToken with name GitHub" - - Solution: Add GitHub PAT token using `az webapp deployment source update-token` - -3. **Git URL Format**: - - Problem: SSH format not supported - - Solution: Use HTTPS format for GitHub repositories - -## Client Integration - -### Android Configuration - -Add to `strings.xml`: - -```xml -https://codepush-devml.azurewebsites.net -``` - -### iOS Configuration - -Add to `Info.plist`: - -```xml -CodePushServerURL -https://codepush-devml.azurewebsites.net -``` - -## Monitoring & Management - -- Deployment status: Azure Portal > App Service > Deployment Center -- Manual deployment: Use "Sync" button in Deployment Center -- Environment variables: Azure Portal > App Service > Configuration > Application settings - -## Next Steps - -1. Verify dev deployment is working correctly -2. Complete production environment deployment if needed -3. Test client integration with mobile apps -4. Establish CI/CD workflow for ongoing development From a629298543d6b9d6ecac8410f123bc86c4274a8e Mon Sep 17 00:00:00 2001 From: Van Allen Diongzon Date: Mon, 14 Apr 2025 20:06:05 +0800 Subject: [PATCH 6/6] [Adjustment][Van] Move the friendly docs to api folder --- FRIENDLY_DOCS.md => api/FRIENDLY_DOCS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename FRIENDLY_DOCS.md => api/FRIENDLY_DOCS.md (100%) diff --git a/FRIENDLY_DOCS.md b/api/FRIENDLY_DOCS.md similarity index 100% rename from FRIENDLY_DOCS.md rename to api/FRIENDLY_DOCS.md