feat: add app_dir input to support monorepo/subdirectory layouts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,17 @@ run-name: 🚀 Deploy ${{ github.event.repository.name }} ${{ github.ref_name }}
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
app_dir:
|
||||||
|
description: "Relative path to the Next.js app within the repository"
|
||||||
|
type: string
|
||||||
|
default: "."
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
app_dir:
|
||||||
|
description: "Relative path to the Next.js app within the repository"
|
||||||
|
type: string
|
||||||
|
default: "."
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
@@ -11,6 +21,7 @@ jobs:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
VAR_APP_NAME: ${{ vars.VAR_APP_NAME }}
|
VAR_APP_NAME: ${{ vars.VAR_APP_NAME }}
|
||||||
|
APP_DIR: ${{ inputs.app_dir || '.' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 📥 Checkout
|
- name: 📥 Checkout
|
||||||
@@ -21,10 +32,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
cache: "npm"
|
cache: "npm"
|
||||||
cache-dependency-path: web/package-lock.json
|
cache-dependency-path: ${{ env.APP_DIR }}/package-lock.json
|
||||||
|
|
||||||
- name: 📦 Install dependencies
|
- name: 📦 Install dependencies
|
||||||
working-directory: web
|
working-directory: ${{ env.APP_DIR }}
|
||||||
run: npm ci --include=dev
|
run: npm ci --include=dev
|
||||||
|
|
||||||
- name: Create Env
|
- name: Create Env
|
||||||
@@ -32,10 +43,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
secrets: ${{ toJSON(secrets) }}
|
secrets: ${{ toJSON(secrets) }}
|
||||||
vars: ${{ toJSON(vars) }}
|
vars: ${{ toJSON(vars) }}
|
||||||
generate-file: "web/.env"
|
generate-file: "${{ env.APP_DIR }}/.env"
|
||||||
|
|
||||||
- name: 🏗️ Build Next.js (Standalone)
|
- name: 🏗️ Build Next.js (Standalone)
|
||||||
working-directory: web
|
working-directory: ${{ env.APP_DIR }}
|
||||||
run: |
|
run: |
|
||||||
npm run build
|
npm run build
|
||||||
test -d .next/standalone || (echo "Standalone build missing" && exit 1)
|
test -d .next/standalone || (echo "Standalone build missing" && exit 1)
|
||||||
@@ -49,14 +60,14 @@ jobs:
|
|||||||
CURRENT_LINK="$DEPLOY_BASE/current"
|
CURRENT_LINK="$DEPLOY_BASE/current"
|
||||||
|
|
||||||
mkdir -p "$RELEASE_DIR"
|
mkdir -p "$RELEASE_DIR"
|
||||||
cp -r web/.next/standalone/. "$RELEASE_DIR/"
|
cp -r "${APP_DIR}/.next/standalone/." "$RELEASE_DIR/"
|
||||||
mkdir -p "$RELEASE_DIR/.next/static"
|
mkdir -p "$RELEASE_DIR/.next/static"
|
||||||
cp -r web/.next/static/. "$RELEASE_DIR/.next/static/"
|
cp -r "${APP_DIR}/.next/static/." "$RELEASE_DIR/.next/static/"
|
||||||
|
|
||||||
if [ -d "web/public" ]; then
|
if [ -d "${APP_DIR}/public" ]; then
|
||||||
cp -r web/public "$RELEASE_DIR/"
|
cp -r "${APP_DIR}/public" "$RELEASE_DIR/"
|
||||||
fi
|
fi
|
||||||
cp web/.env "$RELEASE_DIR/"
|
cp "${APP_DIR}/.env" "$RELEASE_DIR/"
|
||||||
|
|
||||||
SHARED_LOGS="$DEPLOY_BASE/shared/logs"
|
SHARED_LOGS="$DEPLOY_BASE/shared/logs"
|
||||||
mkdir -p "$SHARED_LOGS"
|
mkdir -p "$SHARED_LOGS"
|
||||||
|
|||||||
Reference in New Issue
Block a user