ci-slackbot-proxy.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. yarn 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: Install dependencies
  103. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  104. run: |
  105. yarn 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. run: |
  113. cp packages/slackbot-proxy/config/ci/.env.local.for-ci packages/slackbot-proxy/.env.local
  114. yarn lerna run --scope slackbot-proxy dev:ci
  115. env:
  116. TYPEORM_CONNECTION: mysql
  117. TYPEORM_HOST: localhost
  118. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  119. TYPEORM_DATABASE: growi-slackbot-proxy
  120. TYPEORM_USERNAME: root
  121. TYPEORM_PASSWORD:
  122. - name: Slack Notification
  123. uses: weseek/ghaction-slack-notification@master
  124. if: failure()
  125. with:
  126. type: ${{ job.status }}
  127. job_name: '*Node CI for growi-bot-proxy - launch-dev (${{ matrix.node-version }})*'
  128. channel: '#ci'
  129. isCompactMode: true
  130. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  131. launch-prod:
  132. runs-on: ubuntu-latest
  133. strategy:
  134. matrix:
  135. node-version: [14.x]
  136. services:
  137. mysql:
  138. image: mysql:8.0
  139. ports:
  140. - 3306
  141. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  142. env:
  143. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  144. MYSQL_DATABASE: growi-slackbot-proxy
  145. steps:
  146. - uses: actions/checkout@v2
  147. - name: Use Node.js ${{ matrix.node-version }}
  148. uses: actions/setup-node@v1
  149. with:
  150. node-version: ${{ matrix.node-version }}
  151. - name: Get Date
  152. id: date
  153. run: |
  154. echo ::set-output name=YmdH::$(date '+%Y%m%d%H')
  155. echo ::set-output name=Ymd::$(date '+%Y%m%d')
  156. echo ::set-output name=Ym::$(date '+%Y%m')
  157. echo ::set-output name=Y::$(date '+%Y')
  158. - name: Cache/Restore node_modules
  159. uses: actions/cache@v2
  160. with:
  161. path: node_modules
  162. key: ${{ runner.OS }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.YmdH }}
  163. restore-keys: |
  164. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ymd }}
  165. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Ym }}
  166. ${{ runner.os }}-node_modules_prod-${{ matrix.node-version }}-${{ steps.date.outputs.Y }}
  167. - name: Get yarn cache dir
  168. id: cache-yarn
  169. run: echo "::set-output name=dir::$(yarn cache dir)"
  170. - name: Cache/Restore yarn cache
  171. uses: actions/cache@v2
  172. with:
  173. path: ${{ steps.cache-yarn.outputs.dir }}
  174. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
  175. restore-keys: |
  176. ${{ runner.os }}-yarn-
  177. - name: Install dependencies
  178. run: |
  179. yarn --frozen-lockfile
  180. - name: Print dependencies
  181. run: |
  182. echo -n "node " && node -v
  183. echo -n "npm " && npm -v
  184. yarn list --depth=0
  185. - name: yarn build
  186. run: |
  187. yarn lerna run build
  188. - name: yarn install --production
  189. run: |
  190. yarn lerna exec "yarn install --production"
  191. - name: Print dependencies
  192. run: |
  193. echo -n "node " && node -v
  194. echo -n "npm " && npm -v
  195. yarn list --production --depth=0
  196. - name: yarn start:prod:ci
  197. run: |
  198. cp packages/slackbot-proxy/config/ci/.env.local.for-ci packages/slackbot-proxy/.env.local
  199. yarn lerna run --scope slackbot-proxy start:prod:ci
  200. env:
  201. TYPEORM_CONNECTION: mysql
  202. TYPEORM_HOST: localhost
  203. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  204. TYPEORM_DATABASE: growi-slackbot-proxy
  205. TYPEORM_USERNAME: root
  206. TYPEORM_PASSWORD:
  207. - name: Upload report as artifact
  208. uses: actions/upload-artifact@v2
  209. with:
  210. name: Report
  211. path: report
  212. - name: Slack Notification
  213. uses: weseek/ghaction-slack-notification@master
  214. if: failure()
  215. with:
  216. type: ${{ job.status }}
  217. job_name: '*Node CI for growi-bot-proxy - launch-prod (${{ matrix.node-version }})*'
  218. channel: '#ci'
  219. isCompactMode: true
  220. url: ${{ secrets.SLACK_WEBHOOK_URL }}