ci-slackbot-proxy.yml 7.2 KB

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