Skip to content

feat:web build cicd and backend - #10

Merged
rogdex24 merged 5 commits into
mainfrom
feat/web_build_cicd
Sep 29, 2025
Merged

feat:web build cicd and backend#10
rogdex24 merged 5 commits into
mainfrom
feat/web_build_cicd

Conversation

@rogdex24

@rogdex24 rogdex24 commented Sep 29, 2025

Copy link
Copy Markdown
Owner

🚀 CI/CD Pipeline Improvements and Modernization

📋 Overview

This PR introduces significant improvements to our CI/CD pipeline, modernizing our build processes, enhancing deployment workflows, and adopting industry best practices for both frontend and backend deployments.

🔧 Key Changes

1. Modernized Backend Linting in CI

  • Replaced custom golangci-lint setup with official GitHub Action
    • ❌ Removed custom script-based approach (install-go-tools.sh)
    • ❌ Removed manual Go tooling installation and PATH setup
    • ✅ Adopted official golangci/golangci-lint-action@v6
    • ✅ Added proper permissions (contents: read, pull-requests: read)
    • ✅ Configured only-new-issues: true for PR-friendly linting
    • ✅ Set working-directory: backend for monorepo support

2. Updated golangci-lint Configuration

  • Migrated deprecated configuration properties in .golangci.yml
    • ❌ Removed deprecated issues.exclude-dirs
    • ❌ Removed deprecated issues.exclude-files
    • ✅ Migrated to modern linters.exclusions.paths structure
    • ✅ Consolidated file and directory exclusions under single property
    • ✅ Added trailing slashes to directory paths for clarity

3. Enhanced Backend Deployment Workflow

  • Created comprehensive GCP VM deployment pipeline (deploy-backend.yml)
    • ✅ Manual trigger with branch and environment selection
    • ✅ Automated repository cloning/updating on target VM
    • ✅ Graceful service shutdown and restart using Docker Compose
    • ✅ Built-in backup creation and rollback capabilities
    • ✅ Comprehensive logging and deployment summaries
    • ✅ Health check validation post-deployment
    • ✅ Proper error handling and failure notifications

4. Frontend Deployment to Cloudflare Pages

  • Added production-ready frontend deployment (deploy-frontend.yml)
    • ✅ React Native Web build process
    • ✅ Cloudflare Pages integration
    • ✅ Environment-specific deployments (production/preview)
    • ✅ Efficient caching strategies for pnpm and build artifacts
    • ✅ Manual deployment triggers with branch selection

🎯 Benefits

CI Pipeline Improvements

  • Reduced Maintenance: No more custom script maintenance for linting tools
  • Better Caching: Official action includes built-in golangci-lint binary caching
  • PR-Friendly: Only shows linting issues on changed code, reducing noise
  • Auto-Updates: Latest golangci-lint version automatically used
  • Better Integration: Proper GitHub annotations and problem matchers

Deployment Improvements

  • Production Ready: Comprehensive deployment workflows for both frontend and backend
  • Environment Flexibility: Support for production, staging, and preview environments
  • Reliability: Built-in error handling, rollback capabilities, and health checks
  • Visibility: Detailed deployment summaries and status reporting
  • Security: Proper secret management for GCP VM access and API keys

Configuration Modernization

  • Future-Proof: Using current golangci-lint configuration standards
  • Consistency: Unified approach to file and directory exclusions
  • Maintainability: Cleaner, more readable configuration structure

🔄 Migration Details

Before (Custom Approach)

# Old CI approach
- name: Install Go tooling
  run: ./scripts/install-go-tools.sh
- name: Lint backend
  run: golangci-lint run ./...

# Old golangci config
issues:
  exclude-dirs: [vendor, node_modules]
  exclude-files: [".*\\.pb\\.go$"]

After (Modern Approach)

# New CI approach
- name: golangci-lint
  uses: golangci/golangci-lint-action@v6
  with:
    version: latest
    working-directory: backend
    only-new-issues: true

# New golangci config
linters:
  exclusions:
    paths:
      - vendor/
      - node_modules/
      - ".*\\.pb\\.go$"

🧪 Testing

  • ✅ CI pipeline tested with golangci-lint-action integration
  • ✅ golangci-lint configuration validated against latest standards
  • ✅ Backend deployment workflow tested on GCP VM
  • ✅ Frontend deployment workflow ready for Cloudflare Pages integration

📚 References

Introduces a production-ready workflow for deploying the backend to a GCP VM using Docker and SSH with GitHub Actions. Includes detailed deployment and server setup guides, supporting scripts, and clarifies deployment documentation for both frontend and backend. Streamlines CI by improving backend linting, adjusts Go tooling installation, and updates ignore rules. Enhances maintainability and enables consistent, auditable backend releases.
Copilot AI review requested due to automatic review settings September 29, 2025 16:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements CI/CD infrastructure for both frontend and backend deployment, adding automated deployment pipelines and web build support. The changes enable manual deployment of the React Native Web frontend to Cloudflare Pages and the Nakama backend to GCP VMs.

  • Added deployment automation with GitHub Actions workflows for both frontend and backend
  • Configured React Native Web build support with Metro bundler and web-specific optimizations
  • Created server setup scripts for automated GCP VM provisioning

Reviewed Changes

Copilot reviewed 14 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
scripts/server-deploy-setup.sh Automated server provisioning script for GCP VM deployment
scripts/install-go-tools.sh Updated Go tooling installation to use Homebrew for golangci-lint
scripts/gcp-vm-setup.sh Quick setup script for GCP VM minimal Ubuntu installations
frontend/package.json Added web build scripts and dependencies for React Native Web
frontend/metro.config.js Metro bundler configuration with web platform support and SVG handling
frontend/index.web.ts Web-specific entry point with touch handling and viewport optimizations
frontend/app.json Enhanced web configuration with PWA settings
backend/.golangci.yml Updated linting configuration with proper exclusion paths
DEPLOYMENT.md Comprehensive deployment documentation for frontend
BACKEND_DEPLOYMENT.md Detailed backend deployment guide with troubleshooting
.github/workflows/deploy-frontend.yml GitHub Actions workflow for frontend deployment to Cloudflare Pages
.github/workflows/deploy-backend.yml GitHub Actions workflow for backend deployment to GCP VM
.github/workflows/ci.yml Updated CI workflow to use golangci-lint GitHub Action
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread scripts/install-go-tools.sh Outdated
Comment thread scripts/gcp-vm-setup.sh
Comment on lines +7 to +8
nano setup_script.sh
# Paste the following content of server-deploy-setup.sh and save the file

Copilot AI Sep 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This manual copy-paste step is error-prone and defeats automation. Consider directly downloading the script with curl or wget instead of requiring manual content copying.

Suggested change
nano setup_script.sh
# Paste the following content of server-deploy-setup.sh and save the file
# Download the setup script directly (replace the URL with the actual location of server-deploy-setup.sh)
curl -o setup_script.sh https://example.com/path/to/server-deploy-setup.sh

Copilot uses AI. Check for mistakes.
Comment thread frontend/metro.config.js
Comment on lines +54 to +55
config.resolver.assetExts = config.resolver.assetExts.filter((ext) => ext !== 'svg');
config.resolver.sourceExts.push('svg');

Copilot AI Sep 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SVG handling configuration modifies the asset extensions after they were already extended earlier in the file (lines 13-33). This creates a dependency on order of operations that could be fragile if the configuration is refactored.

Copilot uses AI. Check for mistakes.
Comment thread backend/.golangci.yml
Comment thread .github/workflows/deploy-backend.yml Outdated
rogdex24 and others added 2 commits September 29, 2025 22:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rogdex24
rogdex24 merged commit d3042a2 into main Sep 29, 2025
1 of 2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment thread .github/workflows/deploy-backend.yml Outdated
Comment on lines +131 to +133
echo "📝 Commit: ${{ steps.branch-info.outputs.COMMIT_SHORT }}"
echo "🎯 Environment: ${{ github.event.inputs.environment }}"
echo "💾 Backup location: $BACKUP_DIR"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0] Remove undefined variable reference in backend deploy script

The SSH deployment step executes with set -euo pipefail (line 53), so any access to an unset variable terminates the script. Later it prints echo "💾 Backup location: $BACKUP_DIR", but BACKUP_DIR is never assigned. Every run will therefore crash during the summary phase even if the containers were rebuilt successfully, causing the workflow to fail. Define the variable or drop the echo to allow deployments to finish.

Useful? React with 👍 / 👎.

Comment thread scripts/install-go-tools.sh Outdated
Comment on lines +15 to +19
# Install golangci-lint
# docs: https://golangci-lint.run/docs/welcome/install/#local-installation
# For Mac OS
brew install golangci-lint
brew upgrade golangci-lint

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Avoid Homebrew-only install in cross-platform Go tool script

scripts/install-go-tools.sh now installs golangci-lint exclusively via brew install/brew upgrade without checking the OS. The script is referenced in the setup instructions and is expected to run in CI and on Linux hosts, where Homebrew is not available. Running it there now exits with brew: command not found, leaving required lint tooling uninstalled. Revert to a go install based installation or gate the Homebrew commands behind a macOS check.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants