ci-slackbot-proxy.yml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. name: Node CI for slackbot-proxy
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - rc/**
  7. - support/prepare-v**
  8. paths:
  9. - .github/workflows/ci-slackbot-proxy.yml
  10. - .eslint*
  11. - tsconfig.base.json
  12. - turbo.json
  13. - yarn.lock
  14. - package.json
  15. - apps/slackbot-proxy/**
  16. - '!apps/slackbot-proxy/docker/**'
  17. - packages/slack/**
  18. concurrency:
  19. group: ${{ github.workflow }}-${{ github.ref }}
  20. cancel-in-progress: true
  21. jobs:
  22. lint:
  23. runs-on: ubuntu-latest
  24. strategy:
  25. matrix:
  26. node-version: [18.x]
  27. steps:
  28. - uses: actions/checkout@v3
  29. - uses: actions/setup-node@v3
  30. with:
  31. node-version: ${{ matrix.node-version }}
  32. cache: 'yarn'
  33. cache-dependency-path: '**/yarn.lock'
  34. - name: Cache/Restore node_modules
  35. uses: actions/cache@v3
  36. with:
  37. path: |
  38. **/node_modules
  39. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/slackbot-proxy/package.json') }}
  40. restore-keys: |
  41. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
  42. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  43. - name: Restore dist
  44. uses: actions/cache/restore@v3
  45. with:
  46. path: |
  47. **/.turbo
  48. **/dist
  49. key: dist-slackbot-proxy-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  50. restore-keys: |
  51. dist-slackbot-proxy-ci-${{ runner.OS }}-node${{ matrix.node-version }}-
  52. - name: Install dependencies
  53. run: |
  54. yarn global add turbo@1.10.9
  55. yarn --frozen-lockfile
  56. - name: Lint
  57. run: |
  58. turbo run lint --filter=@growi/slackbot-proxy
  59. - name: Slack Notification
  60. uses: weseek/ghaction-slack-notification@master
  61. if: failure()
  62. with:
  63. type: ${{ job.status }}
  64. job_name: '*Node CI for growi-bot-proxy - test (${{ matrix.node-version }})*'
  65. channel: '#ci'
  66. isCompactMode: true
  67. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  68. - name: Cache dist
  69. uses: actions/cache/save@v3
  70. with:
  71. path: |
  72. **/.turbo
  73. **/dist
  74. key: dist-slackbot-proxy-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  75. launch-dev:
  76. runs-on: ubuntu-latest
  77. strategy:
  78. matrix:
  79. node-version: [18.x]
  80. services:
  81. mysql:
  82. image: mysql:8.0
  83. ports:
  84. - 3306
  85. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  86. env:
  87. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  88. MYSQL_DATABASE: growi-slackbot-proxy
  89. steps:
  90. - uses: actions/checkout@v3
  91. - uses: actions/setup-node@v3
  92. with:
  93. node-version: ${{ matrix.node-version }}
  94. cache: 'yarn'
  95. cache-dependency-path: '**/yarn.lock'
  96. - name: Cache/Restore node_modules
  97. uses: actions/cache@v3
  98. with:
  99. path: |
  100. **/node_modules
  101. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/slackbot-proxy/package.json') }}
  102. restore-keys: |
  103. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
  104. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  105. - name: Restore dist
  106. uses: actions/cache/restore@v3
  107. with:
  108. path: |
  109. **/.turbo
  110. **/dist
  111. key: dist-slackbot-proxy-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  112. restore-keys: |
  113. dist-slackbot-proxy-ci-${{ runner.OS }}-node${{ matrix.node-version }}-
  114. - name: Install dependencies
  115. run: |
  116. yarn global add turbo@1.10.9
  117. yarn --frozen-lockfile
  118. - name: yarn dev:ci
  119. working-directory: ./apps/slackbot-proxy
  120. run: |
  121. cp config/ci/.env.local.for-ci .env.development.local
  122. turbo run dev:ci
  123. env:
  124. SERVER_URI: http://localhost:8080
  125. TYPEORM_CONNECTION: mysql
  126. TYPEORM_HOST: localhost
  127. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  128. TYPEORM_DATABASE: growi-slackbot-proxy
  129. TYPEORM_USERNAME: root
  130. TYPEORM_PASSWORD:
  131. - name: Slack Notification
  132. uses: weseek/ghaction-slack-notification@master
  133. if: failure()
  134. with:
  135. type: ${{ job.status }}
  136. job_name: '*Node CI for growi-bot-proxy - launch-dev (${{ matrix.node-version }})*'
  137. channel: '#ci'
  138. isCompactMode: true
  139. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  140. - name: Cache dist
  141. uses: actions/cache/save@v3
  142. with:
  143. path: |
  144. **/.turbo
  145. **/dist
  146. key: dist-slackbot-proxy-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  147. launch-prod:
  148. runs-on: ubuntu-latest
  149. strategy:
  150. matrix:
  151. node-version: [18.x]
  152. services:
  153. mysql:
  154. image: mysql:8.0
  155. ports:
  156. - 3306
  157. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  158. env:
  159. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  160. MYSQL_DATABASE: growi-slackbot-proxy
  161. steps:
  162. - uses: actions/checkout@v3
  163. - uses: actions/setup-node@v3
  164. with:
  165. node-version: ${{ matrix.node-version }}
  166. cache: 'yarn'
  167. cache-dependency-path: '**/yarn.lock'
  168. - name: Install turbo
  169. run: |
  170. yarn global add turbo@1.10.9
  171. - name: Prune repositories
  172. run: |
  173. turbo prune --scope=@growi/slackbot-proxy
  174. rm -rf apps packages
  175. mv out/* .
  176. - name: Cache/Restore node_modules
  177. id: cache-dependencies
  178. uses: actions/cache@v3
  179. with:
  180. path: |
  181. **/node_modules
  182. key: node_modules-slackbot-prxy-build-prod-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
  183. restore-keys: |
  184. node_modules-slackbot-proxy-build-prod-${{ runner.OS }}-node${{ inputs.node-version }}-
  185. - name: Install dependencies
  186. run: |
  187. yarn --frozen-lockfile
  188. - name: Restore dist
  189. uses: actions/cache/restore@v3
  190. with:
  191. path: |
  192. **/.turbo
  193. **/dist
  194. key: dist-slackbot-proxy-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  195. restore-keys: |
  196. dist-slackbot-proxy-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  197. - name: Build
  198. working-directory: ./apps/slackbot-proxy
  199. run: |
  200. turbo run build
  201. - name: Install dependencies for production
  202. run: |
  203. yarn --production
  204. - name: yarn start:prod:ci
  205. working-directory: ./apps/slackbot-proxy
  206. run: |
  207. cp config/ci/.env.local.for-ci .env.production.local
  208. yarn start:prod:ci
  209. env:
  210. SERVER_URI: http://localhost:8080
  211. TYPEORM_CONNECTION: mysql
  212. TYPEORM_HOST: localhost
  213. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  214. TYPEORM_DATABASE: growi-slackbot-proxy
  215. TYPEORM_USERNAME: root
  216. TYPEORM_PASSWORD:
  217. - name: Slack Notification
  218. uses: weseek/ghaction-slack-notification@master
  219. if: failure()
  220. with:
  221. type: ${{ job.status }}
  222. job_name: '*Node CI for growi-bot-proxy - launch-prod (${{ matrix.node-version }})*'
  223. channel: '#ci'
  224. isCompactMode: true
  225. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  226. - name: Cache dist
  227. uses: actions/cache/save@v3
  228. with:
  229. path: |
  230. **/.turbo
  231. **/dist
  232. key: dist-slackbot-proxy-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}