ci-slackbot-proxy.yml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. name: Node CI for slackbot-proxy
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - tmp/**
  7. paths:
  8. - .github/workflows/ci-slackbot-proxy.yml
  9. - packages/slack/**
  10. - packages/slackbot-proxy/**
  11. - package.json
  12. - yarn.lock
  13. jobs:
  14. test:
  15. runs-on: ubuntu-latest
  16. strategy:
  17. matrix:
  18. node-version: [14.x]
  19. steps:
  20. - uses: actions/checkout@v2
  21. - name: Use Node.js ${{ matrix.node-version }}
  22. uses: actions/setup-node@v1
  23. with:
  24. node-version: ${{ matrix.node-version }}
  25. - name: Cache/Restore node_modules
  26. id: cache-dependencies
  27. uses: actions/cache@v2
  28. with:
  29. path: node_modules
  30. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  31. - name: Get yarn cache dir
  32. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  33. id: cache-yarn
  34. run: echo "::set-output name=dir::$(yarn cache dir)"
  35. - name: Cache/Restore yarn cache
  36. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  37. uses: actions/cache@v2
  38. with:
  39. path: ${{ steps.cache-yarn.outputs.dir }}
  40. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  41. restore-keys: |
  42. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  43. - name: Install dependencies
  44. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  45. run: |
  46. npx lerna bootstrap
  47. - name: Print dependencies
  48. run: |
  49. echo -n "node " && node -v
  50. echo -n "npm " && npm -v
  51. yarn list --depth=0
  52. - name: yarn test
  53. run: |
  54. yarn lerna run test
  55. - name: Slack Notification
  56. uses: weseek/ghaction-slack-notification@master
  57. if: failure()
  58. with:
  59. type: ${{ job.status }}
  60. job_name: '*Node CI for growi-bot-proxy - test (${{ matrix.node-version }})*'
  61. channel: '#ci'
  62. isCompactMode: true
  63. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  64. launch-dev:
  65. runs-on: ubuntu-latest
  66. strategy:
  67. matrix:
  68. node-version: [14.x]
  69. services:
  70. mysql:
  71. image: mysql:8.0
  72. ports:
  73. - 3306
  74. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  75. env:
  76. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  77. MYSQL_DATABASE: growi-slackbot-proxy
  78. steps:
  79. - uses: actions/checkout@v2
  80. - name: Use Node.js ${{ matrix.node-version }}
  81. uses: actions/setup-node@v1
  82. with:
  83. node-version: ${{ matrix.node-version }}
  84. - name: Cache/Restore node_modules
  85. id: cache-dependencies
  86. uses: actions/cache@v2
  87. with:
  88. path: node_modules
  89. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  90. - name: Get yarn cache dir
  91. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  92. id: cache-yarn
  93. run: echo "::set-output name=dir::$(yarn cache dir)"
  94. - name: Cache/Restore yarn cache
  95. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  96. uses: actions/cache@v2
  97. with:
  98. path: ${{ steps.cache-yarn.outputs.dir }}
  99. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  100. restore-keys: |
  101. ${{ runner.os }}-yarn-
  102. - name: lerna bootstrap
  103. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  104. run: |
  105. npx lerna bootstrap
  106. - name: Print dependencies
  107. run: |
  108. echo -n "node " && node -v
  109. echo -n "npm " && npm -v
  110. yarn list --depth=0
  111. - name: yarn dev:ci
  112. working-directory: ./packages/slackbot-proxy
  113. run: |
  114. cp config/ci/.env.local.for-ci .env.local
  115. yarn dev:ci
  116. env:
  117. TYPEORM_CONNECTION: mysql
  118. TYPEORM_HOST: localhost
  119. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  120. TYPEORM_DATABASE: growi-slackbot-proxy
  121. TYPEORM_USERNAME: root
  122. TYPEORM_PASSWORD:
  123. - name: Slack Notification
  124. uses: weseek/ghaction-slack-notification@master
  125. if: failure()
  126. with:
  127. type: ${{ job.status }}
  128. job_name: '*Node CI for growi-bot-proxy - launch-dev (${{ matrix.node-version }})*'
  129. channel: '#ci'
  130. isCompactMode: true
  131. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  132. launch-prod:
  133. runs-on: ubuntu-latest
  134. strategy:
  135. matrix:
  136. node-version: [14.x]
  137. services:
  138. mysql:
  139. image: mysql:8.0
  140. ports:
  141. - 3306
  142. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  143. env:
  144. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  145. MYSQL_DATABASE: growi-slackbot-proxy
  146. steps:
  147. - uses: actions/checkout@v2
  148. - name: Use Node.js ${{ matrix.node-version }}
  149. uses: actions/setup-node@v1
  150. with:
  151. node-version: ${{ matrix.node-version }}
  152. - name: Get Date
  153. id: date
  154. run: |
  155. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  156. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  157. echo ::set-output name=Ym::$(date '+%Y%m')
  158. echo ::set-output name=Y::$(date '+%Y')
  159. - name: Cache/Restore node_modules
  160. uses: actions/cache@v2
  161. with:
  162. path: node_modules
  163. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  164. restore-keys: |
  165. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  166. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  167. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  168. - name: Get yarn cache dir
  169. id: cache-yarn
  170. run: echo "::set-output name=dir::$(yarn cache dir)"
  171. - name: Cache/Restore yarn cache
  172. uses: actions/cache@v2
  173. with:
  174. path: ${{ steps.cache-yarn.outputs.dir }}
  175. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  176. restore-keys: |
  177. ${{ runner.os }}-yarn-
  178. - name: lerna bootstrap
  179. run: |
  180. npx lerna bootstrap
  181. - name: Print dependencies
  182. run: |
  183. echo -n "node " && node -v
  184. echo -n "npm " && npm -v
  185. yarn list --depth=0
  186. - name: lerna run build
  187. run: |
  188. yarn lerna run build
  189. - name: lerna bootstrap --production
  190. run: |
  191. npx lerna bootstrap -- --production
  192. - name: Print dependencies
  193. run: |
  194. echo -n "node " && node -v
  195. echo -n "npm " && npm -v
  196. yarn list --production --depth=0
  197. - name: yarn start:prod:ci
  198. working-directory: ./packages/slackbot-proxy
  199. run: |
  200. cp config/ci/.env.local.for-ci .env.local
  201. yarn start:prod:ci
  202. env:
  203. TYPEORM_CONNECTION: mysql
  204. TYPEORM_HOST: localhost
  205. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  206. TYPEORM_DATABASE: growi-slackbot-proxy
  207. TYPEORM_USERNAME: root
  208. TYPEORM_PASSWORD:
  209. - name: Upload report as artifact
  210. uses: actions/upload-artifact@v2
  211. with:
  212. name: Report
  213. path: report
  214. - name: Slack Notification
  215. uses: weseek/ghaction-slack-notification@master
  216. if: failure()
  217. with:
  218. type: ${{ job.status }}
  219. job_name: '*Node CI for growi-bot-proxy - launch-prod (${{ matrix.node-version }})*'
  220. channel: '#ci'
  221. isCompactMode: true
  222. url: ${{ secrets.SLACK_WEBHOOK_URL }}