@@ -76,6 +76,16 @@ export async function scaffoldMonorepo(projectNameArg, options) {
7676 initial : true
7777 } ) ;
7878 }
79+ if ( options . withActions === undefined ) {
80+ interactiveQuestions . push ( {
81+ type : 'toggle' ,
82+ name : 'withActions' ,
83+ message : 'Generate GitHub Actions CI workflow?' ,
84+ active : 'yes' ,
85+ inactive : 'no' ,
86+ initial : false
87+ } ) ;
88+ }
7989
8090 let answers = { } ;
8191 const nonInteractive = ! ! options . yes || process . env . CI === 'true' ;
@@ -99,6 +109,9 @@ export async function scaffoldMonorepo(projectNameArg, options) {
99109 case 'git' :
100110 answers . git = false ;
101111 break ;
112+ case 'withActions' :
113+ answers . withActions = false ; // default disabled in non-interactive mode
114+ break ;
102115 default :
103116 break ;
104117 }
@@ -126,6 +139,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
126139 options . preset = options . preset || answers . preset || '' ;
127140 options . packageManager = options . packageManager || answers . packageManager || 'npm' ;
128141 if ( options . git === undefined ) options . git = answers . git ;
142+ if ( options . withActions === undefined ) options . withActions = answers . withActions ;
129143
130144 console . log ( chalk . cyanBright ( `\n🚀 Creating ${ projectName } monorepo...\n` ) ) ;
131145
@@ -500,6 +514,25 @@ export async function scaffoldMonorepo(projectNameArg, options) {
500514 }
501515 }
502516
517+ // Optionally generate GitHub Actions workflow
518+ if ( options . withActions ) {
519+ try {
520+ const wfDir = path . join ( projectDir , '.github' , 'workflows' ) ;
521+ await fs . mkdirp ( wfDir ) ;
522+ const wfPath = path . join ( wfDir , 'ci.yml' ) ;
523+ if ( ! ( await fs . pathExists ( wfPath ) ) ) {
524+ const nodeVersion = '20.x' ;
525+ const installStep = pm === 'yarn' ? 'yarn install --frozen-lockfile || yarn install' : pm === 'pnpm' ? 'pnpm install' : pm === 'bun' ? 'bun install' : 'npm ci || npm install' ;
526+ const testCmd = pm === 'yarn' ? 'yarn test' : pm === 'pnpm' ? 'pnpm test' : pm === 'bun' ? 'bun test' : 'npm test' ;
527+ const wf = `# Generated by create-polyglot CI scaffold\nname: CI\n\non:\n push:\n branches: [ main, master ]\n pull_request:\n branches: [ main, master ]\n\njobs:\n build-test:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n - name: Setup Node.js\n uses: actions/setup-node@v4\n with:\n node-version: ${ nodeVersion } \n cache: '${ pm === 'npm' ? 'npm' : pm } '\n - name: Install dependencies\n run: ${ installStep } \n - name: Run tests\n run: ${ testCmd } \n` ;
528+ await fs . writeFile ( wfPath , wf ) ;
529+ console . log ( chalk . green ( '✅ Added GitHub Actions workflow (.github/workflows/ci.yml)' ) ) ;
530+ }
531+ } catch ( e ) {
532+ console . log ( chalk . yellow ( '⚠️ Failed to create GitHub Actions workflow:' ) , e . message ) ;
533+ }
534+ }
535+
503536 // Write polyglot config
504537 const polyglotConfig = {
505538 name : projectName ,
@@ -516,6 +549,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
516549 `${ pm } run list:services # quick list (fancy table)` ,
517550 `${ pm } run dev # run local node/frontend services` ,
518551 'docker compose up --build# run all via docker' ,
552+ options . withActions ? 'GitHub Actions CI ready (see .github/workflows/ci.yml)' : '' ,
519553 '' ,
520554 'Happy hacking!'
521555 ] . filter ( Boolean ) ) ;
0 commit comments