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:
2026-03-10 19:26:31 -03:00
parent 1a3505d398
commit 87ecaaad17

View File

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