@jaypie/mcp 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/createMcpServer.d.ts +7 -1
  2. package/dist/index.js +26 -3135
  3. package/dist/index.js.map +1 -1
  4. package/dist/suite.d.ts +1 -0
  5. package/dist/suite.js +2442 -0
  6. package/dist/suite.js.map +1 -0
  7. package/package.json +8 -3
  8. package/release-notes/constructs/1.2.17.md +11 -0
  9. package/release-notes/fabric/0.1.2.md +11 -0
  10. package/release-notes/fabric/0.1.3.md +25 -0
  11. package/release-notes/fabric/0.1.4.md +42 -0
  12. package/release-notes/mcp/0.3.3.md +12 -0
  13. package/release-notes/mcp/0.3.4.md +36 -0
  14. package/release-notes/mcp/0.4.0.md +27 -0
  15. package/release-notes/testkit/1.2.15.md +23 -0
  16. package/skills/agents.md +25 -0
  17. package/skills/aws.md +107 -0
  18. package/skills/cdk.md +141 -0
  19. package/skills/cicd.md +152 -0
  20. package/skills/datadog.md +129 -0
  21. package/skills/debugging.md +148 -0
  22. package/skills/dns.md +134 -0
  23. package/skills/dynamodb.md +140 -0
  24. package/skills/errors.md +142 -0
  25. package/skills/fabric.md +191 -0
  26. package/skills/index.md +7 -0
  27. package/skills/jaypie.md +100 -0
  28. package/skills/legacy.md +97 -0
  29. package/skills/logs.md +160 -0
  30. package/skills/mocks.md +174 -0
  31. package/skills/models.md +195 -0
  32. package/skills/releasenotes.md +94 -0
  33. package/skills/secrets.md +155 -0
  34. package/skills/services.md +175 -0
  35. package/skills/style.md +190 -0
  36. package/skills/tests.md +209 -0
  37. package/skills/tools.md +127 -0
  38. package/skills/topics.md +116 -0
  39. package/skills/variables.md +146 -0
  40. package/skills/writing.md +153 -0
  41. package/prompts/Branch_Management.md +0 -34
  42. package/prompts/Development_Process.md +0 -89
  43. package/prompts/Jaypie_Agent_Rules.md +0 -110
  44. package/prompts/Jaypie_Auth0_Express_Mongoose.md +0 -736
  45. package/prompts/Jaypie_Browser_and_Frontend_Web_Packages.md +0 -18
  46. package/prompts/Jaypie_CDK_Constructs_and_Patterns.md +0 -430
  47. package/prompts/Jaypie_CICD_with_GitHub_Actions.md +0 -371
  48. package/prompts/Jaypie_Commander_CLI_Package.md +0 -166
  49. package/prompts/Jaypie_Core_Errors_and_Logging.md +0 -39
  50. package/prompts/Jaypie_DynamoDB_Package.md +0 -774
  51. package/prompts/Jaypie_Eslint_NPM_Package.md +0 -78
  52. package/prompts/Jaypie_Express_Package.md +0 -630
  53. package/prompts/Jaypie_Fabric_Commander.md +0 -411
  54. package/prompts/Jaypie_Fabric_LLM.md +0 -312
  55. package/prompts/Jaypie_Fabric_Lambda.md +0 -308
  56. package/prompts/Jaypie_Fabric_MCP.md +0 -316
  57. package/prompts/Jaypie_Fabric_Package.md +0 -513
  58. package/prompts/Jaypie_Fabricator.md +0 -617
  59. package/prompts/Jaypie_Ideal_Project_Structure.md +0 -78
  60. package/prompts/Jaypie_Init_CICD_with_GitHub_Actions.md +0 -1186
  61. package/prompts/Jaypie_Init_Express_on_Lambda.md +0 -115
  62. package/prompts/Jaypie_Init_Jaypie_CDK_Package.md +0 -35
  63. package/prompts/Jaypie_Init_Lambda_Package.md +0 -505
  64. package/prompts/Jaypie_Init_Monorepo_Project.md +0 -44
  65. package/prompts/Jaypie_Init_Project_Subpackage.md +0 -65
  66. package/prompts/Jaypie_Legacy_Patterns.md +0 -15
  67. package/prompts/Jaypie_Llm_Calls.md +0 -449
  68. package/prompts/Jaypie_Llm_Tools.md +0 -155
  69. package/prompts/Jaypie_MCP_Package.md +0 -281
  70. package/prompts/Jaypie_Mocks_and_Testkit.md +0 -137
  71. package/prompts/Jaypie_Repokit.md +0 -103
  72. package/prompts/Jaypie_Scrub.md +0 -177
  73. package/prompts/Jaypie_Streaming.md +0 -467
  74. package/prompts/Templates_CDK_Subpackage.md +0 -115
  75. package/prompts/Templates_Express_Subpackage.md +0 -187
  76. package/prompts/Templates_Project_Monorepo.md +0 -326
  77. package/prompts/Templates_Project_Subpackage.md +0 -93
  78. package/prompts/Write_Efficient_Prompt_Guides.md +0 -48
  79. package/prompts/Write_and_Maintain_Engaging_Readme.md +0 -67
@@ -1,1186 +0,0 @@
1
- ---
2
- description: step-by-step guide to initialize GitHub Actions CI/CD for Jaypie projects
3
- ---
4
-
5
- # Initialize CI/CD with GitHub Actions
6
-
7
- This guide walks through setting up GitHub Actions CI/CD from scratch for a Jaypie project.
8
-
9
- ## Workspace Naming Conventions
10
-
11
- | Directory | Purpose |
12
- |-----------|---------|
13
- | `packages/` | Default workspace for npm packages (preferred when only one namespace needed) |
14
- | `stacks/` | CDK-deployed infrastructure and sites (as opposed to npm-published) |
15
- | `workspaces/` | Generic workspace for other work |
16
-
17
- ## Prerequisites
18
-
19
- - GitHub repository with Jaypie project structure
20
- - AWS account with OIDC provider configured for GitHub Actions
21
- - GitHub environments configured (development, sandbox, production)
22
-
23
- ## Directory Structure
24
-
25
- Create the following structure:
26
-
27
- ```
28
- .github/
29
- ├── actions/
30
- │ ├── cdk-deploy/
31
- │ │ └── action.yml
32
- │ ├── configure-aws/
33
- │ │ └── action.yml
34
- │ ├── npm-install-build/
35
- │ │ └── action.yml
36
- │ ├── setup-environment/
37
- │ │ └── action.yml
38
- │ └── setup-node-and-cache/
39
- │ └── action.yml
40
- └── workflows/
41
- ├── check-production.yml
42
- ├── deploy-env-development.yml
43
- ├── deploy-env-production.yml
44
- ├── deploy-env-sandbox.yml
45
- └── version.yml
46
- ```
47
-
48
- ## Step 1: Create Composite Actions
49
-
50
- Composite actions provide reusable workflow steps. Create each file in `.github/actions/`.
51
-
52
- ### configure-aws/action.yml
53
-
54
- Configures AWS credentials using OIDC.
55
-
56
- ```yaml
57
- name: Configure AWS Credentials
58
- description: Configure AWS credentials using OIDC for GitHub Actions
59
-
60
- inputs:
61
- role-arn:
62
- description: AWS IAM role ARN to assume
63
- required: true
64
- aws-region:
65
- description: AWS region
66
- required: false
67
- default: us-east-1
68
- role-session-name:
69
- description: Name for the role session
70
- required: false
71
- default: DeployRoleForGitHubSession
72
-
73
- runs:
74
- using: composite
75
- steps:
76
- - name: Configure AWS Credentials
77
- uses: aws-actions/configure-aws-credentials@v4
78
- with:
79
- role-to-assume: ${{ inputs.role-arn }}
80
- role-session-name: ${{ inputs.role-session-name }}
81
- aws-region: ${{ inputs.aws-region }}
82
- ```
83
-
84
- ### setup-node-and-cache/action.yml
85
-
86
- Sets up Node.js with caching for dependencies.
87
-
88
- ```yaml
89
- name: Setup Node.js and Cache Dependencies
90
- description: Checkout code, setup Node.js with npm cache, and configure dependency caching
91
-
92
- inputs:
93
- node-version:
94
- description: Node.js version to use
95
- required: false
96
- default: "24"
97
-
98
- outputs:
99
- node-modules-cache-hit:
100
- description: Whether node_modules cache was hit
101
- value: ${{ steps.cache-node-modules.outputs.cache-hit }}
102
-
103
- runs:
104
- using: composite
105
- steps:
106
- - name: Checkout code
107
- uses: actions/checkout@v4
108
-
109
- - name: Setup Node.js ${{ inputs.node-version }}
110
- uses: actions/setup-node@v4
111
- with:
112
- cache: npm
113
- node-version: ${{ inputs.node-version }}
114
-
115
- - name: Cache node_modules
116
- id: cache-node-modules
117
- uses: actions/cache@v4
118
- with:
119
- path: |
120
- node_modules
121
- packages/*/node_modules
122
- stacks/*/node_modules
123
- key: ${{ runner.os }}-node-${{ inputs.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
124
- restore-keys: |
125
- ${{ runner.os }}-node-${{ inputs.node-version }}-modules-
126
-
127
- - name: Cache Status
128
- shell: bash
129
- run: |
130
- echo "Node modules cache: ${{ steps.cache-node-modules.outputs.cache-hit == 'true' && '✓ HIT' || '✗ MISS' }}"
131
- ```
132
-
133
- ### npm-install-build/action.yml
134
-
135
- Installs dependencies and builds the project.
136
-
137
- ```yaml
138
- name: NPM Install and Build
139
- description: Install dependencies and build the project
140
-
141
- inputs:
142
- use-ci:
143
- description: Use npm ci instead of npm install (recommended for CI/CD)
144
- required: false
145
- default: "true"
146
- build-command:
147
- description: NPM script to run for building
148
- required: false
149
- default: build
150
-
151
- runs:
152
- using: composite
153
- steps:
154
- - name: Install dependencies
155
- shell: bash
156
- run: |
157
- if [ "${{ inputs.use-ci }}" = "true" ]; then
158
- npm ci
159
- else
160
- npm install
161
- fi
162
-
163
- - name: Build project
164
- shell: bash
165
- run: npm run ${{ inputs.build-command }}
166
- ```
167
-
168
- ### setup-environment/action.yml
169
-
170
- Configures environment variables with sensible defaults. Customize the defaults for your project.
171
-
172
- ```yaml
173
- name: Setup Environment Variables
174
- description: |
175
- Configure environment variables with sensible defaults for Jaypie projects.
176
-
177
- Variable Scoping (GitHub Settings):
178
- - Organization: AWS_REGION, LOG_LEVEL, MODULE_LOG_LEVEL, PROJECT_SPONSOR
179
- - Repository: AWS_HOSTED_ZONE, PROJECT_KEY, PROJECT_SERVICE
180
- - Environment: AWS_ROLE_ARN, DATADOG_API_KEY_ARN, PROJECT_ENV, PROJECT_NONCE
181
-
182
- Environment Secrets:
183
- - By default, no secrets are required
184
- - Dependencies add secrets (e.g., Auth0 adds AUTH0_CLIENT_SECRET)
185
- - Secrets are passed to CDK via JaypieEnvSecret construct
186
-
187
- inputs:
188
- # Organization-level variables
189
- aws-region:
190
- description: AWS region (org-level)
191
- required: false
192
- log-level:
193
- description: Application log level (org-level)
194
- required: false
195
- module-log-level:
196
- description: Module log level (org-level)
197
- required: false
198
- project-sponsor:
199
- description: Project sponsor (org-level)
200
- required: false
201
- # Repository-level variables
202
- aws-hosted-zone:
203
- description: Route53 hosted zone (repo-level)
204
- required: false
205
- project-key:
206
- description: Project key (repo-level)
207
- required: false
208
- project-service:
209
- description: Project service name (repo-level)
210
- required: false
211
- # Environment-level variables
212
- aws-role-arn:
213
- description: AWS IAM role ARN (env-level)
214
- required: false
215
- datadog-api-key-arn:
216
- description: Datadog API key ARN (env-level)
217
- required: false
218
- project-env:
219
- description: Project environment (env-level)
220
- required: false
221
- project-nonce:
222
- description: Project nonce (env-level)
223
- required: false
224
-
225
- outputs:
226
- aws-region:
227
- description: Resolved AWS region
228
- value: ${{ steps.set-env.outputs.aws-region }}
229
- aws-role-arn:
230
- description: Resolved AWS role ARN
231
- value: ${{ steps.set-env.outputs.aws-role-arn }}
232
- project-env:
233
- description: Resolved project environment
234
- value: ${{ steps.set-env.outputs.project-env }}
235
-
236
- runs:
237
- using: composite
238
- steps:
239
- - name: Set environment variables
240
- id: set-env
241
- shell: bash
242
- run: |
243
- # Organization-level variables (with defaults)
244
- AWS_REGION="${{ inputs.aws-region }}"
245
- AWS_REGION="${AWS_REGION:-us-east-1}"
246
-
247
- LOG_LEVEL="${{ inputs.log-level }}"
248
- LOG_LEVEL="${LOG_LEVEL:-debug}"
249
-
250
- MODULE_LOG_LEVEL="${{ inputs.module-log-level }}"
251
- MODULE_LOG_LEVEL="${MODULE_LOG_LEVEL:-warn}"
252
-
253
- PROJECT_SPONSOR="${{ inputs.project-sponsor }}"
254
- PROJECT_SPONSOR="${PROJECT_SPONSOR:-myorg}"
255
-
256
- # Repository-level variables (with defaults)
257
- HOSTED_ZONE="${{ inputs.aws-hosted-zone }}"
258
- HOSTED_ZONE="${HOSTED_ZONE:-example.com}"
259
-
260
- PROJECT_KEY="${{ inputs.project-key }}"
261
- PROJECT_KEY="${PROJECT_KEY:-myapp}"
262
-
263
- PROJECT_SERVICE="${{ inputs.project-service }}"
264
- PROJECT_SERVICE="${PROJECT_SERVICE:-stacks}"
265
-
266
- # Environment-level variables (with defaults)
267
- AWS_ROLE_ARN="${{ inputs.aws-role-arn }}"
268
-
269
- DATADOG_API_KEY_ARN="${{ inputs.datadog-api-key-arn }}"
270
-
271
- PROJECT_ENV="${{ inputs.project-env }}"
272
- PROJECT_ENV="${PROJECT_ENV:-sandbox}"
273
-
274
- PROJECT_NONCE="${{ inputs.project-nonce }}"
275
- PROJECT_NONCE="${PROJECT_NONCE:-$(echo $RANDOM | md5sum | head -c 8)}"
276
-
277
- # Derived from package.json
278
- PROJECT_VERSION=$(node -p "require('./package.json').version")
279
-
280
- # Export all environment variables for CDK
281
- echo "AWS_REGION=${AWS_REGION}" >> $GITHUB_ENV
282
- echo "AWS_ROLE_ARN=${AWS_ROLE_ARN}" >> $GITHUB_ENV
283
- echo "CDK_DEFAULT_ACCOUNT=${{ github.repository_owner }}" >> $GITHUB_ENV
284
- echo "CDK_DEFAULT_REGION=${AWS_REGION}" >> $GITHUB_ENV
285
- echo "CDK_ENV_DATADOG_API_KEY_ARN=${DATADOG_API_KEY_ARN}" >> $GITHUB_ENV
286
- echo "CDK_ENV_HOSTED_ZONE=${HOSTED_ZONE}" >> $GITHUB_ENV
287
- echo "CDK_ENV_REPO=${{ github.repository }}" >> $GITHUB_ENV
288
- echo "LOG_LEVEL=${LOG_LEVEL}" >> $GITHUB_ENV
289
- echo "MODULE_LOG_LEVEL=${MODULE_LOG_LEVEL}" >> $GITHUB_ENV
290
- echo "PROJECT_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
291
- echo "PROJECT_ENV=${PROJECT_ENV}" >> $GITHUB_ENV
292
- echo "PROJECT_KEY=${PROJECT_KEY}" >> $GITHUB_ENV
293
- echo "PROJECT_NONCE=${PROJECT_NONCE}" >> $GITHUB_ENV
294
- echo "PROJECT_SERVICE=${PROJECT_SERVICE}" >> $GITHUB_ENV
295
- echo "PROJECT_SPONSOR=${PROJECT_SPONSOR}" >> $GITHUB_ENV
296
- echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV
297
-
298
- # Set outputs for subsequent steps
299
- echo "aws-region=${AWS_REGION}" >> $GITHUB_OUTPUT
300
- echo "aws-role-arn=${AWS_ROLE_ARN}" >> $GITHUB_OUTPUT
301
- echo "project-env=${PROJECT_ENV}" >> $GITHUB_OUTPUT
302
- ```
303
-
304
- ### cdk-deploy/action.yml
305
-
306
- Builds and deploys CDK stack with caching.
307
-
308
- ```yaml
309
- name: CDK Build and Deploy
310
- description: Build and deploy AWS CDK stack with caching
311
-
312
- inputs:
313
- stack-name:
314
- description: CDK stack name to deploy
315
- required: true
316
- cdk-package-path:
317
- description: Path to CDK package
318
- required: false
319
- default: packages/cdk
320
-
321
- runs:
322
- using: composite
323
- steps:
324
- - name: Cache CDK build
325
- id: cache-cdk
326
- uses: actions/cache@v4
327
- with:
328
- path: ${{ inputs.cdk-package-path }}/dist
329
- key: ${{ runner.os }}-cdk-build-${{ hashFiles(format('{0}/package.json', inputs.cdk-package-path), format('{0}/package-lock.json', inputs.cdk-package-path), format('{0}/tsconfig.json', inputs.cdk-package-path), format('{0}/bin/**', inputs.cdk-package-path), format('{0}/lib/**', inputs.cdk-package-path)) }}
330
- restore-keys: |
331
- ${{ runner.os }}-cdk-build-
332
-
333
- - name: CDK Cache Status
334
- shell: bash
335
- run: |
336
- if [ "${{ steps.cache-cdk.outputs.cache-hit }}" == "true" ]; then
337
- echo "✓ CDK build cache HIT - skipping rebuild"
338
- else
339
- echo "✗ CDK build cache MISS - will rebuild"
340
- fi
341
-
342
- - name: Build CDK
343
- if: steps.cache-cdk.outputs.cache-hit != 'true'
344
- shell: bash
345
- run: npm --prefix ${{ inputs.cdk-package-path }} run build
346
-
347
- - name: Deploy CDK Stack
348
- shell: bash
349
- run: npm --workspace ${{ inputs.cdk-package-path }} run cdk deploy -- ${{ inputs.stack-name }} --require-approval never
350
- ```
351
-
352
- ## Step 2: Create Workflow Files
353
-
354
- Create workflow files in `.github/workflows/`.
355
-
356
- ### deploy-env-sandbox.yml
357
-
358
- Deploys to sandbox on feature branches. Lint and test run in parallel with deploy.
359
-
360
- ```yaml
361
- name: Build to Sandbox
362
-
363
- on:
364
- push:
365
- branches:
366
- - feat/*
367
- - sandbox/*
368
- tags:
369
- - sandbox-*
370
-
371
- concurrency:
372
- group: deploy-env-sandbox
373
-
374
- jobs:
375
- deploy:
376
- environment: sandbox
377
- name: Deploy to AWS
378
- permissions:
379
- id-token: write
380
- contents: read
381
- runs-on: ubuntu-latest
382
- steps:
383
- - name: Checkout code
384
- uses: actions/checkout@v4
385
-
386
- - name: Setup Environment
387
- id: setup-env
388
- uses: ./.github/actions/setup-environment
389
- with:
390
- aws-hosted-zone: ${{ vars.AWS_HOSTED_ZONE }}
391
- aws-region: ${{ vars.AWS_REGION }}
392
- aws-role-arn: ${{ vars.AWS_ROLE_ARN }}
393
- datadog-api-key-arn: ${{ vars.DATADOG_API_KEY_ARN }}
394
- log-level: ${{ vars.LOG_LEVEL }}
395
- module-log-level: ${{ vars.MODULE_LOG_LEVEL }}
396
- project-env: ${{ vars.PROJECT_ENV }}
397
- project-key: ${{ vars.PROJECT_KEY }}
398
- project-nonce: ${{ vars.PROJECT_NONCE }}
399
- project-service: ${{ vars.PROJECT_SERVICE }}
400
- project-sponsor: ${{ vars.PROJECT_SPONSOR }}
401
-
402
- - name: Configure AWS Credentials
403
- uses: ./.github/actions/configure-aws
404
- with:
405
- aws-region: ${{ steps.setup-env.outputs.aws-region }}
406
- role-arn: ${{ steps.setup-env.outputs.aws-role-arn }}
407
-
408
- - name: Setup Node.js and Cache
409
- uses: ./.github/actions/setup-node-and-cache
410
- with:
411
- node-version: 24
412
-
413
- - name: Install and Build
414
- uses: ./.github/actions/npm-install-build
415
-
416
- - name: Deploy CDK Stack
417
- uses: ./.github/actions/cdk-deploy
418
- with:
419
- stack-name: AppStack
420
-
421
- lint:
422
- name: Lint
423
- runs-on: ubuntu-latest
424
- steps:
425
- - name: Checkout code
426
- uses: actions/checkout@v4
427
-
428
- - name: Setup Node.js and Cache
429
- id: setup-cache
430
- uses: ./.github/actions/setup-node-and-cache
431
- with:
432
- node-version: 24
433
-
434
- - name: Install dependencies
435
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
436
- run: npm ci
437
-
438
- - name: Build
439
- run: npm run build
440
-
441
- - name: Run Lint
442
- run: npm run lint
443
-
444
- test:
445
- name: Unit Test
446
- runs-on: ubuntu-latest
447
- strategy:
448
- matrix:
449
- node-version: [22, 24]
450
- steps:
451
- - name: Checkout code
452
- uses: actions/checkout@v4
453
-
454
- - name: Setup Node.js ${{ matrix.node-version }} and Cache
455
- id: setup-cache
456
- uses: ./.github/actions/setup-node-and-cache
457
- with:
458
- node-version: ${{ matrix.node-version }}
459
-
460
- - name: Install dependencies
461
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
462
- run: npm ci
463
-
464
- - name: Build
465
- run: npm run build
466
-
467
- - name: Run Tests
468
- run: npm test
469
- ```
470
-
471
- ### deploy-env-development.yml
472
-
473
- Deploys to development from main branch. Requires lint and test to pass.
474
-
475
- ```yaml
476
- name: Build to Development
477
-
478
- on:
479
- push:
480
- branches:
481
- - main
482
- - development/*
483
- tags:
484
- - development-*
485
-
486
- concurrency:
487
- group: deploy-env-development
488
-
489
- jobs:
490
- deploy:
491
- environment: development
492
- needs: [lint, test]
493
- name: Deploy to AWS
494
- permissions:
495
- id-token: write
496
- contents: read
497
- runs-on: ubuntu-latest
498
- steps:
499
- - name: Checkout code
500
- uses: actions/checkout@v4
501
-
502
- - name: Setup Environment
503
- id: setup-env
504
- uses: ./.github/actions/setup-environment
505
- with:
506
- aws-hosted-zone: ${{ vars.AWS_HOSTED_ZONE }}
507
- aws-region: ${{ vars.AWS_REGION }}
508
- aws-role-arn: ${{ vars.AWS_ROLE_ARN }}
509
- datadog-api-key-arn: ${{ vars.DATADOG_API_KEY_ARN }}
510
- log-level: ${{ vars.LOG_LEVEL }}
511
- module-log-level: ${{ vars.MODULE_LOG_LEVEL }}
512
- project-env: ${{ vars.PROJECT_ENV }}
513
- project-key: ${{ vars.PROJECT_KEY }}
514
- project-nonce: ${{ vars.PROJECT_NONCE }}
515
- project-service: ${{ vars.PROJECT_SERVICE }}
516
- project-sponsor: ${{ vars.PROJECT_SPONSOR }}
517
-
518
- - name: Configure AWS Credentials
519
- uses: ./.github/actions/configure-aws
520
- with:
521
- aws-region: ${{ steps.setup-env.outputs.aws-region }}
522
- role-arn: ${{ steps.setup-env.outputs.aws-role-arn }}
523
-
524
- - name: Setup Node.js and Cache
525
- uses: ./.github/actions/setup-node-and-cache
526
- with:
527
- node-version: 24
528
-
529
- - name: Install and Build
530
- uses: ./.github/actions/npm-install-build
531
-
532
- - name: Deploy CDK Stack
533
- uses: ./.github/actions/cdk-deploy
534
- with:
535
- stack-name: AppStack
536
-
537
- lint:
538
- name: Lint
539
- runs-on: ubuntu-latest
540
- steps:
541
- - name: Checkout code
542
- uses: actions/checkout@v4
543
-
544
- - name: Setup Node.js and Cache
545
- id: setup-cache
546
- uses: ./.github/actions/setup-node-and-cache
547
- with:
548
- node-version: 24
549
-
550
- - name: Install dependencies
551
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
552
- run: npm ci
553
-
554
- - name: Build
555
- run: npm run build
556
-
557
- - name: Run Lint
558
- run: npm run lint
559
-
560
- test:
561
- name: Unit Test
562
- runs-on: ubuntu-latest
563
- strategy:
564
- matrix:
565
- node-version: [22, 24]
566
- steps:
567
- - name: Checkout code
568
- uses: actions/checkout@v4
569
-
570
- - name: Setup Node.js ${{ matrix.node-version }} and Cache
571
- id: setup-cache
572
- uses: ./.github/actions/setup-node-and-cache
573
- with:
574
- node-version: ${{ matrix.node-version }}
575
-
576
- - name: Install dependencies
577
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
578
- run: npm ci
579
-
580
- - name: Build
581
- run: npm run build
582
-
583
- - name: Run Tests
584
- run: npm test
585
- ```
586
-
587
- ### deploy-env-production.yml
588
-
589
- Deploys to production from version tags. Requires lint and test to pass.
590
-
591
- ```yaml
592
- name: Build to Production
593
-
594
- on:
595
- push:
596
- tags:
597
- - 'production-*'
598
- - 'v0.*'
599
- - 'v1.*'
600
-
601
- concurrency:
602
- group: deploy-env-production
603
-
604
- jobs:
605
- deploy:
606
- environment: production
607
- needs: [lint, test]
608
- if: |
609
- always() &&
610
- needs.lint.result == 'success' &&
611
- needs.test.result == 'success'
612
- name: Deploy to AWS
613
- permissions:
614
- id-token: write
615
- contents: read
616
- runs-on: ubuntu-latest
617
- steps:
618
- - name: Checkout code
619
- uses: actions/checkout@v4
620
-
621
- - name: Display deployment version
622
- run: |
623
- VERSION=$(node -p "require('./package.json').version")
624
- echo "::notice::Deploying version $VERSION to production"
625
- echo "DEPLOY_VERSION=$VERSION" >> $GITHUB_ENV
626
-
627
- - name: Setup Environment
628
- id: setup-env
629
- uses: ./.github/actions/setup-environment
630
- with:
631
- aws-hosted-zone: ${{ vars.AWS_HOSTED_ZONE }}
632
- aws-region: ${{ vars.AWS_REGION }}
633
- aws-role-arn: ${{ vars.AWS_ROLE_ARN }}
634
- datadog-api-key-arn: ${{ vars.DATADOG_API_KEY_ARN }}
635
- log-level: ${{ vars.LOG_LEVEL }}
636
- module-log-level: ${{ vars.MODULE_LOG_LEVEL }}
637
- project-env: ${{ vars.PROJECT_ENV }}
638
- project-key: ${{ vars.PROJECT_KEY }}
639
- project-nonce: ${{ vars.PROJECT_NONCE }}
640
- project-service: ${{ vars.PROJECT_SERVICE }}
641
- project-sponsor: ${{ vars.PROJECT_SPONSOR }}
642
-
643
- - name: Configure AWS Credentials
644
- uses: ./.github/actions/configure-aws
645
- with:
646
- aws-region: ${{ steps.setup-env.outputs.aws-region }}
647
- role-arn: ${{ steps.setup-env.outputs.aws-role-arn }}
648
-
649
- - name: Setup Node.js and Cache
650
- uses: ./.github/actions/setup-node-and-cache
651
- with:
652
- node-version: 24
653
-
654
- - name: Install and Build
655
- uses: ./.github/actions/npm-install-build
656
-
657
- - name: Deploy CDK Stack
658
- uses: ./.github/actions/cdk-deploy
659
- with:
660
- stack-name: AppStack
661
-
662
- lint:
663
- name: Lint
664
- runs-on: ubuntu-latest
665
- steps:
666
- - name: Checkout code
667
- uses: actions/checkout@v4
668
-
669
- - name: Setup Node.js and Cache
670
- id: setup-cache
671
- uses: ./.github/actions/setup-node-and-cache
672
- with:
673
- node-version: 24
674
-
675
- - name: Install dependencies
676
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
677
- run: npm ci
678
-
679
- - name: Build
680
- run: npm run build
681
-
682
- - name: Run Lint
683
- run: npm run lint
684
-
685
- test:
686
- name: Unit Test
687
- runs-on: ubuntu-latest
688
- strategy:
689
- matrix:
690
- node-version: [22, 24]
691
- steps:
692
- - name: Checkout code
693
- uses: actions/checkout@v4
694
-
695
- - name: Setup Node.js ${{ matrix.node-version }} and Cache
696
- id: setup-cache
697
- uses: ./.github/actions/setup-node-and-cache
698
- with:
699
- node-version: ${{ matrix.node-version }}
700
-
701
- - name: Install dependencies
702
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
703
- run: npm ci
704
-
705
- - name: Build
706
- run: npm run build
707
-
708
- - name: Run Tests
709
- run: npm test
710
- ```
711
-
712
- ### check-production.yml
713
-
714
- Runs checks on production branches without deploying.
715
-
716
- ```yaml
717
- name: Check Production Build
718
-
719
- on:
720
- push:
721
- branches:
722
- - production
723
- - production-*
724
- - production/*
725
-
726
- concurrency:
727
- group: check-production
728
-
729
- jobs:
730
- lint:
731
- name: Lint
732
- runs-on: ubuntu-latest
733
- steps:
734
- - name: Checkout code
735
- uses: actions/checkout@v4
736
-
737
- - name: Setup Node.js and Cache
738
- id: setup-cache
739
- uses: ./.github/actions/setup-node-and-cache
740
- with:
741
- node-version: 24
742
-
743
- - name: Install dependencies
744
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
745
- run: npm ci
746
-
747
- - name: Build
748
- run: npm run build
749
-
750
- - name: Run Lint
751
- run: npm run lint
752
-
753
- test:
754
- name: Unit Test
755
- runs-on: ubuntu-latest
756
- strategy:
757
- matrix:
758
- node-version: [22, 24]
759
- steps:
760
- - name: Checkout code
761
- uses: actions/checkout@v4
762
-
763
- - name: Setup Node.js ${{ matrix.node-version }} and Cache
764
- id: setup-cache
765
- uses: ./.github/actions/setup-node-and-cache
766
- with:
767
- node-version: ${{ matrix.node-version }}
768
-
769
- - name: Install dependencies
770
- if: steps.setup-cache.outputs.node-modules-cache-hit != 'true'
771
- run: npm ci
772
-
773
- - name: Build
774
- run: npm run build
775
-
776
- - name: Run Tests
777
- run: npm test
778
- ```
779
-
780
- ### version.yml
781
-
782
- Updates version across monorepo packages.
783
-
784
- ```yaml
785
- name: Update Version
786
-
787
- on:
788
- workflow_dispatch:
789
- inputs:
790
- version_type:
791
- description: 'Version update type'
792
- required: true
793
- type: choice
794
- options:
795
- - patch
796
- - minor
797
- - major
798
- - custom
799
- default: patch
800
- custom_version:
801
- description: 'Custom version (e.g., 1.2.3) - only used if version_type is custom'
802
- required: false
803
- type: string
804
- workflow_call:
805
- inputs:
806
- version_type:
807
- description: 'Version update type'
808
- required: false
809
- type: string
810
- default: patch
811
- custom_version:
812
- description: 'Custom version (e.g., 1.2.3) - only used if version_type is custom'
813
- required: false
814
- type: string
815
- outputs:
816
- new_version:
817
- description: 'The new version number'
818
- value: ${{ jobs.version.outputs.new_version }}
819
-
820
- jobs:
821
- version:
822
- name: Update and Sync Version
823
- runs-on: ubuntu-latest
824
- permissions:
825
- contents: write
826
- outputs:
827
- new_version: ${{ steps.bump.outputs.new_version }}
828
- steps:
829
- - name: Checkout code
830
- uses: actions/checkout@v4
831
- with:
832
- token: ${{ secrets.GITHUB_TOKEN }}
833
-
834
- - name: Setup Node.js
835
- uses: actions/setup-node@v4
836
- with:
837
- node-version: 24
838
-
839
- - name: Configure Git
840
- run: |
841
- git config user.name "github-actions[bot]"
842
- git config user.email "github-actions[bot]@users.noreply.github.com"
843
-
844
- - name: Update root version
845
- id: bump
846
- run: |
847
- VERSION_TYPE="${{ inputs.version_type }}"
848
- CUSTOM_VERSION="${{ inputs.custom_version }}"
849
-
850
- if [[ "$VERSION_TYPE" == "custom" ]]; then
851
- if [[ -z "$CUSTOM_VERSION" ]]; then
852
- echo "Error: custom_version is required when version_type is 'custom'"
853
- exit 1
854
- fi
855
- npm version "$CUSTOM_VERSION" --no-git-tag-version --allow-same-version
856
- else
857
- npm version "$VERSION_TYPE" --no-git-tag-version
858
- fi
859
-
860
- NEW_VERSION=$(node -p "require('./package.json').version")
861
- echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
862
- echo "Updated to version $NEW_VERSION"
863
-
864
- - name: Sync package versions
865
- run: |
866
- NEW_VERSION="${{ steps.bump.outputs.new_version }}"
867
- echo "Syncing all packages to version $NEW_VERSION"
868
-
869
- for pkg in packages/*/package.json; do
870
- if [ -f "$pkg" ]; then
871
- echo "Updating $pkg"
872
- node -e "
873
- const fs = require('fs');
874
- const pkg = JSON.parse(fs.readFileSync('$pkg', 'utf8'));
875
- pkg.version = '$NEW_VERSION';
876
- fs.writeFileSync('$pkg', JSON.stringify(pkg, null, 2) + '\n');
877
- "
878
- fi
879
- done
880
-
881
- - name: Commit and push changes
882
- run: |
883
- git add package.json package-lock.json packages/*/package.json
884
- git commit -m "chore: version: ${{ steps.bump.outputs.new_version }}"
885
- git push
886
- ```
887
-
888
- ## Step 3: Configure GitHub Variables
889
-
890
- Variables are configured at different levels in GitHub Settings.
891
-
892
- ### Variable Scoping
893
-
894
- | Level | Variables | Where to Configure |
895
- |-------|-----------|-------------------|
896
- | Organization | AWS_REGION, LOG_LEVEL, MODULE_LOG_LEVEL, PROJECT_SPONSOR | Settings → Actions → Variables |
897
- | Repository | AWS_HOSTED_ZONE, PROJECT_KEY, PROJECT_SERVICE | Settings → Actions secrets and variables → Variables |
898
- | Environment | AWS_ROLE_ARN, DATADOG_API_KEY_ARN, PROJECT_ENV, PROJECT_NONCE | Settings → Environments → [env] → Variables |
899
-
900
- ### Creating an Environment
901
-
902
- 1. Go to your repository on GitHub
903
- 2. Navigate to **Settings → Environments**
904
- 3. Click **New environment**
905
- 4. Name it (e.g., `sandbox`, `development`, `production`)
906
- 5. Click **Configure environment**
907
- 6. Under **Environment variables**, click **Add variable** for each variable
908
-
909
- ### Required Variables (Environment Level)
910
-
911
- | Variable | Description | Example |
912
- |----------|-------------|---------|
913
- | `AWS_ROLE_ARN` | IAM role ARN for OIDC (deployment fails without this) | `arn:aws:iam::123456789:role/DeployRole` |
914
- | `PROJECT_ENV` | Environment identifier | `sandbox`, `development`, `production` |
915
-
916
- ### Optional Variables
917
-
918
- | Variable | Level | Description | Default |
919
- |----------|-------|-------------|---------|
920
- | `AWS_REGION` | Org | AWS region | `us-east-1` |
921
- | `AWS_HOSTED_ZONE` | Repo | Route53 hosted zone | `example.com` |
922
- | `DATADOG_API_KEY_ARN` | Env | Secrets Manager ARN for Datadog | (none) |
923
- | `LOG_LEVEL` | Org | Application log level | `debug` |
924
- | `MODULE_LOG_LEVEL` | Org | Module log level | `warn` |
925
- | `PROJECT_KEY` | Repo | Project identifier | (from package.json name) |
926
- | `PROJECT_NONCE` | Env | Unique identifier for resources | (random) |
927
- | `PROJECT_SERVICE` | Repo | Service name | `stacks` |
928
- | `PROJECT_SPONSOR` | Org | Organization name | (from repository owner) |
929
-
930
- ### Auto-Generated Variables
931
-
932
- These variables are set automatically from GitHub context:
933
-
934
- | Variable | Source | Description |
935
- |----------|--------|-------------|
936
- | `CDK_DEFAULT_ACCOUNT` | `${{ github.repository_owner }}` | Repository owner |
937
- | `CDK_DEFAULT_REGION` | `AWS_REGION` | Same as AWS region |
938
- | `CDK_ENV_REPO` | `${{ github.repository }}` | Repository name (owner/repo) |
939
- | `PROJECT_COMMIT` | `${{ github.sha }}` | Current commit SHA |
940
- | `PROJECT_VERSION` | `package.json` | Version from package.json |
941
-
942
- ### Environment Secrets
943
-
944
- By default, no secrets are required. Dependencies add secrets as needed.
945
-
946
- Secrets are passed to CDK via `JaypieEnvSecret` construct and made available at runtime.
947
-
948
- Navigate to: **Settings → Environments → [environment] → Environment secrets**
949
-
950
- #### Example: Auth0 Integration
951
-
952
- When adding Auth0 authentication:
953
-
954
- **Environment Variables:**
955
- - `AUTH0_AUDIENCE` - API identifier
956
- - `AUTH0_CLIENT_ID` - Application client ID
957
- - `AUTH0_DOMAIN` - Auth0 tenant domain
958
-
959
- **Environment Secrets:**
960
- - `AUTH0_CLIENT_SECRET` - Application client secret
961
-
962
- Add to workflow:
963
- ```yaml
964
- - name: Deploy CDK Stack
965
- uses: ./.github/actions/cdk-deploy
966
- with:
967
- stack-name: AppStack
968
- env:
969
- AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
970
- ```
971
-
972
- ### Deployment Protection Rules (Optional)
973
-
974
- You can add protection rules to any environment:
975
-
976
- - **Required reviewers**: Require manual approval before deploying
977
- - **Wait timer**: Delay deployment by a specified time
978
- - **Deployment branches**: Limit which branches can deploy
979
-
980
- ### How Variables Are Resolved
981
-
982
- GitHub Actions composite actions cannot access `vars.*` directly. Variables must be passed as action inputs.
983
-
984
- The workflow passes variables to `setup-environment`, which applies defaults:
985
-
986
- ```yaml
987
- jobs:
988
- deploy:
989
- environment: sandbox # Variables from this environment
990
- steps:
991
- - name: Setup Environment
992
- id: setup-env
993
- uses: ./.github/actions/setup-environment
994
- with:
995
- aws-region: ${{ vars.AWS_REGION }}
996
- aws-role-arn: ${{ vars.AWS_ROLE_ARN }}
997
- # ... other vars
998
-
999
- # Access resolved values via outputs
1000
- - name: Configure AWS
1001
- uses: ./.github/actions/configure-aws
1002
- with:
1003
- role-arn: ${{ steps.setup-env.outputs.aws-role-arn }}
1004
- aws-region: ${{ steps.setup-env.outputs.aws-region }}
1005
- ```
1006
-
1007
- ### Environment Configuration by Target
1008
-
1009
- | Environment | `PROJECT_ENV` | `LOG_LEVEL` | Notes |
1010
- |-------------|---------------|-------------|-------|
1011
- | sandbox | `sandbox` | `debug` or `trace` | Shared testing |
1012
- | development | `development` | `debug` | Validates multi-env deployment |
1013
- | production | `production` | `info` | Less verbose logging |
1014
-
1015
- ## Step 4: Configure AWS OIDC
1016
-
1017
- Create an IAM role in AWS that trusts GitHub Actions OIDC provider.
1018
-
1019
- ### Trust Policy
1020
-
1021
- ```json
1022
- {
1023
- "Version": "2012-10-17",
1024
- "Statement": [
1025
- {
1026
- "Effect": "Allow",
1027
- "Principal": {
1028
- "Federated": "arn:aws:iam::ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com"
1029
- },
1030
- "Action": "sts:AssumeRoleWithWebIdentity",
1031
- "Condition": {
1032
- "StringEquals": {
1033
- "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
1034
- },
1035
- "StringLike": {
1036
- "token.actions.githubusercontent.com:sub": "repo:ORG/REPO:*"
1037
- }
1038
- }
1039
- }
1040
- ]
1041
- }
1042
- ```
1043
-
1044
- ### Required Permissions
1045
-
1046
- The role needs permissions for:
1047
- - CDK deployment (CloudFormation, IAM, Lambda, etc.)
1048
- - Any resources your stack creates
1049
-
1050
- ## Step 5: Verify Setup
1051
-
1052
- 1. Push to a feature branch to trigger sandbox deployment
1053
- 2. Merge to main to trigger development deployment
1054
- 3. Create a version tag to trigger production deployment
1055
-
1056
- ```bash
1057
- # Test sandbox
1058
- git checkout -b feat/test-cicd
1059
- git push origin feat/test-cicd
1060
-
1061
- # Test development
1062
- git checkout main
1063
- git push origin main
1064
-
1065
- # Test production
1066
- git tag v0.1.0
1067
- git push origin v0.1.0
1068
- ```
1069
-
1070
- ## Customization
1071
-
1072
- ### Adding Application Secrets
1073
-
1074
- Pass secrets to the CDK deploy action by extending `cdk-deploy/action.yml`:
1075
-
1076
- ```yaml
1077
- inputs:
1078
- api-key:
1079
- description: API key for external service
1080
- required: false
1081
-
1082
- # In the Deploy step:
1083
- env:
1084
- API_KEY: ${{ inputs.api-key }}
1085
- ```
1086
-
1087
- Then in workflows:
1088
-
1089
- ```yaml
1090
- - name: Deploy CDK Stack
1091
- uses: ./.github/actions/cdk-deploy
1092
- with:
1093
- stack-name: AppStack
1094
- api-key: ${{ secrets.API_KEY }}
1095
- ```
1096
-
1097
- ### Adding Framework-Specific Caching
1098
-
1099
- Extend `setup-node-and-cache/action.yml` for framework builds:
1100
-
1101
- ```yaml
1102
- - name: Cache Next.js build
1103
- id: cache-nextjs
1104
- uses: actions/cache@v4
1105
- with:
1106
- path: packages/nextjs/.next
1107
- key: ${{ runner.os }}-nextjs-${{ hashFiles('packages/nextjs/**/*.ts', 'packages/nextjs/**/*.tsx') }}
1108
- ```
1109
-
1110
- ### Personal Builds
1111
-
1112
- For personal sandbox builds, create `deploy-personal-build.yml`:
1113
-
1114
- ```yaml
1115
- name: Personal Build
1116
-
1117
- on:
1118
- push:
1119
- branches-ignore:
1120
- - main
1121
- - develop
1122
- - nobuild-*
1123
- - nobuild/*
1124
- - sandbox
1125
- - sandbox-*
1126
- - sandbox/*
1127
-
1128
- concurrency:
1129
- group: deploy-personal-build-${{ github.actor }}
1130
-
1131
- jobs:
1132
- deploy:
1133
- environment: sandbox
1134
- # ... same as sandbox deploy but with PROJECT_ENV set to github.actor
1135
- ```
1136
-
1137
- ## Troubleshooting
1138
-
1139
- ### "The environment 'sandbox' does not exist"
1140
-
1141
- The environment must be created in GitHub repository settings before the workflow can reference it. See [Creating an Environment](#creating-an-environment).
1142
-
1143
- ### OIDC Authentication Fails / "Unable to assume AWS role"
1144
-
1145
- - Verify `AWS_ROLE_ARN` variable is set correctly in the environment
1146
- - Verify the OIDC provider is configured in AWS IAM
1147
- - Check the trust policy matches your repository
1148
- - Ensure the workflow has `id-token: write` permission
1149
- - Verify the role has necessary permissions for CDK deployment
1150
-
1151
- ### Cache Miss on Every Build
1152
-
1153
- - Verify `package-lock.json` is committed
1154
- - Check cache key patterns match your file structure
1155
-
1156
- ### CDK Deployment Fails
1157
-
1158
- - Verify AWS credentials are configured correctly
1159
- - Check CDK is bootstrapped in the target account/region: `npx cdk bootstrap`
1160
- - If using Datadog, verify `DATADOG_API_KEY_ARN` points to a valid secret
1161
- - Verify the AWS role has permissions to access any Secrets Manager secrets
1162
- - Review CloudFormation events in the AWS Console for specific errors
1163
-
1164
- ### Error: "Cannot retrieve value from context provider hosted-zone"
1165
-
1166
- Stacks using context providers must extend `JaypieAppStack`, not `cdk.Stack`:
1167
-
1168
- ```typescript
1169
- // Wrong
1170
- import * as cdk from "aws-cdk-lib";
1171
- export class AppStack extends cdk.Stack { ... }
1172
-
1173
- // Correct
1174
- import { JaypieAppStack } from "@jaypie/constructs";
1175
- export class AppStack extends JaypieAppStack { ... }
1176
- ```
1177
-
1178
- `JaypieAppStack` automatically sets `env` with `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION`.
1179
-
1180
- ### Variables Not Being Applied
1181
-
1182
- - Composite actions cannot access `vars.*` directly
1183
- - Verify variables are passed as inputs to `setup-environment`
1184
- - Check the environment name in the job matches the GitHub environment name
1185
- - Verify variable names match exactly (case-sensitive)
1186
-