From 7c4056db9750a50f62b4e27f1dcfd8e8ab09ef4c Mon Sep 17 00:00:00 2001 From: laveshparyani Date: Thu, 5 Mar 2026 10:25:19 +0530 Subject: [PATCH] feat: setup tiered CI/CD for Dev (GH Pages) and Main (Hostinger) --- .github/workflows/deploy.yml | 56 +++++++++++++++--------------------- apps/web/next.config.js | 6 ++-- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 34c2b82..4e38051 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,31 +1,20 @@ -# Sample workflow for building and deploying a Next.js site to GitHub Pages -# -# To get started with Next.js see: https://nextjs.org/docs/getting-started -# -name: Deploy Next.js site to Pages +name: Multi-Tier Deployment on: - # Runs on pushes targeting the default branch push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab + branches: ["main", "dev"] workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" cancel-in-progress: false jobs: - # Build job build: runs-on: ubuntu-latest steps: @@ -40,16 +29,6 @@ jobs: echo "command=ci" >> $GITHUB_OUTPUT echo "runner=npx --no-install" >> $GITHUB_OUTPUT exit 0 - elif [ -f "${{ github.workspace }}/yarn.lock" ]; then - echo "manager=yarn" >> $GITHUB_OUTPUT - echo "command=install" >> $GITHUB_OUTPUT - echo "runner=yarn" >> $GITHUB_OUTPUT - exit 0 - elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then - echo "manager=pnpm" >> $GITHUB_OUTPUT - echo "command=install" >> $GITHUB_OUTPUT - echo "runner=pnpm" >> $GITHUB_OUTPUT - exit 0 else echo "Unable to determine package manager" exit 1 @@ -62,12 +41,9 @@ jobs: cache: ${{ steps.detect-package-manager.outputs.manager }} - name: Setup Pages + if: github.ref == 'refs/heads/dev' uses: actions/configure-pages@v5 with: - # Automatically inject basePath in your Next.js configuration file and disable - # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). - # - # You may remove this line if you want to manage the configuration yourself. static_site_generator: next - name: Install dependencies @@ -78,17 +54,31 @@ jobs: working-directory: ./apps/web env: NODE_ENV: production - BASE_PATH: /RestroFX - NEXT_PUBLIC_BASE_PATH: /RestroFX - ASSET_PREFIX: /RestroFX/ + BASE_PATH: ${{ github.ref == 'refs/heads/dev' && '/RestroFX' || '' }} + NEXT_PUBLIC_BASE_PATH: ${{ github.ref == 'refs/heads/dev' && '/RestroFX' || '' }} + ASSET_PREFIX: ${{ github.ref == 'refs/heads/dev' && '/RestroFX/' || '' }} - - name: Upload artifact + - name: Upload GitHub Pages artifact + if: github.ref == 'refs/heads/dev' uses: actions/upload-pages-artifact@v3 with: path: ./apps/web/out - # Deployment job - deploy: + - name: Deploy to Hostinger + if: github.ref == 'refs/heads/main' + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + ARGS: "-rlgoDzvc -i" + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + REMOTE_PORT: ${{ secrets.REMOTE_PORT }} + SOURCE: "apps/web/out/" + TARGET: "public_html/" + EXCLUDE: "/dist/, /node_modules/" + + deploy-github-pages: + if: github.ref == 'refs/heads/dev' environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} diff --git a/apps/web/next.config.js b/apps/web/next.config.js index cd010a7..e13edf4 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -4,11 +4,11 @@ const nextConfig = { output: 'export', // basePath for GitHub Pages - will be overridden by GitHub Actions if it injects it // Set explicitly for production builds to ensure it's available during build - basePath: process.env.BASE_PATH || (process.env.NODE_ENV === 'production' ? '/RestroFX' : ''), + basePath: process.env.BASE_PATH || '', trailingSlash: true, - // assetPrefix must match basePath (with trailing slash) for GitHub Pages + // assetPrefix must match basePath (with trailing slash) // This ensures CSS, JS, and other assets load correctly - assetPrefix: process.env.ASSET_PREFIX || (process.env.NODE_ENV === 'production' ? '/RestroFX/' : ''), + assetPrefix: process.env.ASSET_PREFIX || '', transpilePackages: ["@crimsonfx/ui", "@crimsonfx/utils", "@crimsonfx/types"], images: { unoptimized: true,