|
1 | | - |
2 | 1 | name: Build App |
3 | 2 |
|
4 | 3 | on: |
@@ -44,33 +43,19 @@ jobs: |
44 | 43 | path: | |
45 | 44 | node_modules |
46 | 45 | packages/**/node_modules |
47 | | - !node_modules/.cache |
48 | | - key: node-modules-${{ hashFiles('package.json', 'package-lock.json') }} |
| 46 | + key: node-modules-${{ hashFiles('package.json', 'package-lock.json', 'patches/*') }} |
49 | 47 |
|
50 | | - - name: Install Dependencies |
| 48 | + - name: Optionally Install Node Modules |
51 | 49 | if: steps.cache-node-modules.outputs.cache-hit != 'true' |
52 | 50 | run: npm ci |
53 | 51 |
|
54 | | - # - name: Link to node_modules - App |
55 | | - # if: steps.cache-node-modules.outputs.cache-hit != 'true' |
56 | | - # working-directory: packages/app/node_modules/.bin |
57 | | - # run: | |
58 | | - # ln -s ../../../../node_modules/.bin/next |
59 | | - |
60 | | - - name: Install Node-Prune |
61 | | - run: npm run install:node-prune |
62 | | - |
63 | | - - name: Restore Next.js Build Cache |
64 | | - uses: actions/cache@v3 |
65 | | - with: |
66 | | - # See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node |
67 | | - path: | |
68 | | - ${{ github.workspace }}/packages/app/.next/cache |
69 | | - # Generate a new cache whenever packages or source files change. |
70 | | - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} |
71 | | - # If source files changed but packages didn't, rebuild from a prior cache. |
72 | | - restore-keys: | |
73 | | - ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- |
| 52 | + # - name: Cache App Build Node Modules |
| 53 | + # id: cache-node-modules-app |
| 54 | + # uses: actions/cache@v3 |
| 55 | + # with: |
| 56 | + # path: | |
| 57 | + # packages/app/node_modules |
| 58 | + # key: node-modules-app-${{ hashFiles('package.json', 'packages/app/package-lock.json', 'packages/app/patches/*') }} |
74 | 59 |
|
75 | 60 | # Fixes errors due to JSII tsconfig.json not ignoring libs |
76 | 61 | # node_modules/flatpickr/dist/types/instance.d.ts(37,21): error TS2304: Cannot find name 'Node'. |
@@ -104,60 +89,48 @@ jobs: |
104 | 89 | run: | |
105 | 90 | npx -w ${APP_PACKAGE_NAME} microapps-publish nextjs-version -n ${{ inputs.packageVersion }} |
106 | 91 |
|
107 | | - - name: Build Next.js App |
| 92 | + # outputTracing can't follow modules in npm workspaces |
| 93 | + # npm will not install modules in a workspace folder if there |
| 94 | + # is a package.json in the parent folder, so move it out of the way |
| 95 | + - name: Install Runtime Deps for outputTracing |
| 96 | + # if: steps.cache-node-modules-app.outputs.cache-hit != 'true' |
| 97 | + working-directory: packages/app/ |
108 | 98 | run: | |
109 | | - npm run build:next |
| 99 | + mv ../../package.json ../../package.json.hide |
| 100 | + du -sh node_modules |
| 101 | + npm ci |
| 102 | + du -sh node_modules |
| 103 | + mv ../../package.json.hide ../../package.json |
110 | 104 |
|
111 | | - - name: Cache Runtime Node Modules |
112 | | - id: cache-runtime-node-modules |
| 105 | + - name: Restore Next.js Build Cache |
113 | 106 | uses: actions/cache@v3 |
114 | 107 | with: |
115 | 108 | path: | |
116 | | - packages/app-entry/runtime-deps/node_modules |
117 | | - !packages/app-entry/runtime-deps/node_modules/.cache |
118 | | - key: node-modules-${{ hashFiles('packages/app-entry/runtime-deps/package.json', 'packages/app-entry/runtime-deps/package-lock.json') }} |
119 | | - |
120 | | - - name: Install Runtime Deps for Runtime |
121 | | - if: steps.cache-runtime-node-modules.outputs.cache-hit != 'true' |
122 | | - working-directory: packages/app-entry/runtime-deps/ |
123 | | - run: | |
124 | | - npm ci --omit=dev |
| 109 | + ${{ github.workspace }}/packages/app/.next/cache |
| 110 | + # Generate a new cache whenever packages or patches change. |
| 111 | + key: nextjs-${{ runner.os }}-${{ hashFiles('packages/app/package-lock.json', 'packages/app/patches/*', 'packages/app/next.config.js') }} }} |
125 | 112 |
|
126 | | - - name: Remove Extraneous Files from Runtime Deps |
127 | | - working-directory: packages/app-entry/runtime-deps/ |
| 113 | + - name: Build Next.js App |
| 114 | + working-directory: packages/app/ |
128 | 115 | run: | |
129 | | - node-prune |
130 | | - # Remove the SWC files from the runtime deps (these are dev time only) |
131 | | - rm -rf node_modules/@next/swc-* |
| 116 | + npm run build |
| 117 | + du -sh .next/* |
| 118 | + du -sh .next/standalone/* |
| 119 | + du -sh .next/standalone/.next/* |
132 | 120 |
|
133 | 121 | - name: Combine Build Outputs |
134 | 122 | run: | |
135 | | - mkdir -p ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }} |
136 | | - mkdir -p ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/.static_files/ |
137 | | - cp -R ./packages/app/public/* ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/.static_files/ |
138 | | - cp -R ./packages/app/.next ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }} |
139 | | - rm -rf ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/.next/cache |
140 | | - cp -R ./packages/app/next.config.js ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }} |
141 | | - cp -R ./packages/app-entry/runtime-deps/node_modules ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }} |
142 | | - cp -R ./packages/app-entry/run.sh ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }} |
143 | | - cp -R ./packages/app-entry/server.js ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }} |
144 | | -
|
145 | | - # Prevent the static files from getting pulled into the Lambda |
146 | | - - name: Remove Static Files from App Build |
147 | | - working-directory: packages/cdk-construct/lib/ |
148 | | - run: | |
149 | | - mkdir -p ${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/.static_files/_next/ |
150 | | - mv ${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/.next/static ${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/.static_files/_next |
151 | | -
|
152 | | - - name: Build the NPM tarball for Examination |
153 | | - working-directory: packages/cdk-construct/ |
154 | | - run: | |
155 | | - npm pack |
156 | | - - name: Upload NPM tarball |
157 | | - uses: actions/upload-artifact@v3 |
158 | | - with: |
159 | | - name: cdk_npm_package |
160 | | - path: packages/cdk-construct/pwrdrvr-microapps-app-${{ env.APP_NAME }}-cdk-${{ inputs.packageVersion }}.tgz |
| 123 | + mkdir -p ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/static_files/_next/static |
| 124 | + mkdir -p ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/server/.next |
| 125 | + cp -R ./packages/app/.next/static/* ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/static_files/_next/static/ |
| 126 | + cp -R ./packages/app/public/* ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/static_files/ |
| 127 | + cp -R ./packages/app/.next/standalone/* ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/server/ |
| 128 | + cp -R ./packages/app/.next/standalone/.next/* ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/server/.next/ |
| 129 | + cp -R ./packages/app/run.sh ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/server/ |
| 130 | + du -sh ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/* |
| 131 | + du -sh ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/server/* |
| 132 | + du -sh ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/server/.next/* |
| 133 | + du -sh ./packages/cdk-construct/lib/${{ inputs.APP_CONSTRUCT_FOLDER_NAME }}/static_files/* |
161 | 134 |
|
162 | 135 | # Upload Artifact |
163 | 136 | - name: Zip Package |
|
0 commit comments