reusable-app-prod.yml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. name: Reusable build app workflow for production
  2. on:
  3. workflow_call:
  4. inputs:
  5. node-version:
  6. required: true
  7. type: string
  8. skip-e2e-test:
  9. type: boolean
  10. secrets:
  11. SLACK_WEBHOOK_URL:
  12. required: true
  13. jobs:
  14. build-prod:
  15. runs-on: ubuntu-latest
  16. outputs:
  17. PROD_FILES: ${{ steps.archive-prod-files.outputs.file }}
  18. steps:
  19. - uses: actions/checkout@v4
  20. - name: Install Git LFS
  21. run: |
  22. git lfs install
  23. - uses: pnpm/action-setup@v4
  24. - uses: actions/setup-node@v4
  25. with:
  26. node-version: ${{ inputs.node-version }}
  27. cache: 'pnpm'
  28. - name: Install turbo
  29. run: |
  30. pnpm add turbo --global
  31. - name: Install dependencies
  32. run: |
  33. pnpm install --frozen-lockfile
  34. - name: Cache/Restore dist
  35. uses: actions/cache@v4
  36. with:
  37. path: |
  38. **/.turbo
  39. **/dist
  40. **/node_modules/.cache/turbo
  41. ${{ github.workspace }}/apps/app/.next
  42. key: dist-app-prod-${{ runner.OS }}-node${{ inputs.node-version }}-${{ github.sha }}
  43. restore-keys: |
  44. dist-app-prod-${{ runner.OS }}-node${{ inputs.node-version }}-
  45. - name: Build
  46. working-directory: ./apps/app
  47. run: |
  48. turbo run build --env-mode=loose
  49. env:
  50. ANALYZE: 1
  51. - name: Assembling all dependencies
  52. run: |
  53. rm -rf out
  54. pnpm deploy out --prod --filter @growi/app
  55. rm -rf apps/app/node_modules && mv out/node_modules apps/app/node_modules
  56. - name: Archive production files
  57. id: archive-prod-files
  58. run: |
  59. tar -zcf production.tar.gz --exclude ./apps/app/.next/cache \
  60. package.json \
  61. apps/app/.next \
  62. apps/app/config \
  63. apps/app/dist \
  64. apps/app/public \
  65. apps/app/resource \
  66. apps/app/tmp \
  67. apps/app/.env.production* \
  68. apps/app/node_modules \
  69. apps/app/package.json
  70. echo "file=production.tar.gz" >> $GITHUB_OUTPUT
  71. - name: Upload production files as artifact
  72. uses: actions/upload-artifact@v4
  73. with:
  74. name: Production Files (node${{ inputs.node-version }})
  75. path: ${{ steps.archive-prod-files.outputs.file }}
  76. - name: Upload report as artifact
  77. uses: actions/upload-artifact@v4
  78. with:
  79. name: Bundle Analyzing Report (node${{ inputs.node-version }})
  80. path: |
  81. apps/app/.next/analyze
  82. - name: Slack Notification
  83. uses: weseek/ghaction-slack-notification@master
  84. if: failure()
  85. with:
  86. type: ${{ job.status }}
  87. job_name: '*Node CI for growi - build-prod (${{ inputs.node-version }})*'
  88. channel: '#ci'
  89. isCompactMode: true
  90. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  91. launch-prod:
  92. needs: [build-prod]
  93. runs-on: ubuntu-latest
  94. services:
  95. mongodb:
  96. image: mongo:6.0
  97. ports:
  98. - 27017/tcp
  99. elasticsearch:
  100. image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
  101. ports:
  102. - 9200/tcp
  103. env:
  104. discovery.type: single-node
  105. steps:
  106. - uses: actions/checkout@v4
  107. - uses: pnpm/action-setup@v4
  108. - uses: actions/setup-node@v4
  109. with:
  110. node-version: ${{ inputs.node-version }}
  111. cache: 'pnpm'
  112. - name: Download production files artifact
  113. uses: actions/download-artifact@v4
  114. with:
  115. name: Production Files (node${{ inputs.node-version }})
  116. - name: Extract procution files
  117. run: |
  118. tar -xf ${{ needs.build-prod.outputs.PROD_FILES }}
  119. - name: pnpm run server:ci
  120. working-directory: ./apps/app
  121. run: |
  122. cp config/ci/.env.local.for-ci .env.production.local
  123. pnpm run server:ci
  124. env:
  125. MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
  126. ELASTICSEARCH_URI: http://localhost:${{ job.services.elasticsearch.ports['9200'] }}/growi
  127. - name: Slack Notification
  128. uses: weseek/ghaction-slack-notification@master
  129. if: failure()
  130. with:
  131. type: ${{ job.status }}
  132. job_name: '*Node CI for growi - build-prod (${{ inputs.node-version }})*'
  133. channel: '#ci'
  134. isCompactMode: true
  135. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  136. run-playwright:
  137. needs: [build-prod]
  138. runs-on: ubuntu-latest
  139. container:
  140. # Match the Playwright version
  141. # https://github.com/microsoft/playwright/issues/20010
  142. image: mcr.microsoft.com/playwright:v1.46.0-jammy
  143. strategy:
  144. fail-fast: false
  145. matrix:
  146. browser: [chromium, firefox, webkit]
  147. shard: [1/2, 2/2]
  148. services:
  149. mongodb:
  150. image: mongo:6.0
  151. ports:
  152. - 27017/tcp
  153. elasticsearch:
  154. image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
  155. ports:
  156. - 9200/tcp
  157. env:
  158. discovery.type: single-node
  159. steps:
  160. - uses: actions/checkout@v4
  161. - uses: pnpm/action-setup@v4
  162. - uses: actions/setup-node@v4
  163. with:
  164. node-version: ${{ inputs.node-version }}
  165. cache: 'pnpm'
  166. - name: Install dependencies
  167. run: |
  168. pnpm install --frozen-lockfile
  169. - name: Install Playwright browsers
  170. run: |
  171. pnpm playwright install --with-deps ${{ matrix.browser }}
  172. - name: Download production files artifact
  173. uses: actions/download-artifact@v4
  174. with:
  175. name: Production Files (node${{ inputs.node-version }})
  176. - name: Extract procution files
  177. run: |
  178. tar -xf ${{ needs.build-prod.outputs.PROD_FILES }}
  179. - name: Copy dotenv file for ci
  180. working-directory: ./apps/app
  181. run: |
  182. cat config/ci/.env.local.for-ci >> .env.production.local
  183. - name: Playwright Run (--project=chromium/installer)
  184. if: ${{ matrix.browser == 'chromium' }}
  185. working-directory: ./apps/app
  186. run: |
  187. pnpm playwright test --project=chromium/installer
  188. env:
  189. HOME: /root # ref: https://github.com/microsoft/playwright/issues/6500
  190. MONGO_URI: mongodb://mongodb:27017/growi-playwright-installer
  191. ELASTICSEARCH_URI: http://localhost:${{ job.services.elasticsearch.ports['9200'] }}/growi
  192. - name: Copy dotenv file for automatic installation
  193. working-directory: ./apps/app
  194. run: |
  195. cat config/ci/.env.local.for-auto-install >> .env.production.local
  196. - name: Playwright Run
  197. working-directory: ./apps/app
  198. run: |
  199. pnpm playwright test --project=${{ matrix.browser }} --shard=${{ matrix.shard }}
  200. env:
  201. HOME: /root # ref: https://github.com/microsoft/playwright/issues/6500
  202. MONGO_URI: mongodb://mongodb:27017/growi-playwright
  203. ELASTICSEARCH_URI: http://localhost:${{ job.services.elasticsearch.ports['9200'] }}/growi
  204. - name: Copy dotenv file for automatic installation with allowing guest mode
  205. working-directory: ./apps/app
  206. run: |
  207. cat config/ci/.env.local.for-auto-install-with-allowing-guest >> .env.production.local
  208. - name: Playwright Run (--project=${browser}/guest-mode)
  209. working-directory: ./apps/app
  210. run: |
  211. pnpm playwright test --project=${{ matrix.browser }}/guest-mode --shard=${{ matrix.shard }}
  212. env:
  213. HOME: /root # ref: https://github.com/microsoft/playwright/issues/6500
  214. MONGO_URI: mongodb://mongodb:27017/growi-playwright-guest-mode
  215. ELASTICSEARCH_URI: http://localhost:${{ job.services.elasticsearch.ports['9200'] }}/growi
  216. - name: Slack Notification
  217. uses: weseek/ghaction-slack-notification@master
  218. if: failure()
  219. with:
  220. type: ${{ job.status }}
  221. job_name: '*Node CI for growi - run-playwright*'
  222. channel: '#ci'
  223. isCompactMode: true
  224. url: ${{ secrets.SLACK_WEBHOOK_URL }}