ci-slackbot-proxy.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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/slackbot-proxy/*
  10. - package.json
  11. - yarn.lock
  12. defaults:
  13. run:
  14. working-directory: packages/slackbot-proxy
  15. jobs:
  16. test:
  17. runs-on: ubuntu-latest
  18. strategy:
  19. matrix:
  20. node-version: [14.x]
  21. steps:
  22. - uses: actions/checkout@v2
  23. - name: Use Node.js ${{ matrix.node-version }}
  24. uses: actions/setup-node@v1
  25. with:
  26. node-version: ${{ matrix.node-version }}
  27. - name: Cache/Restore node_modules
  28. id: cache-dependencies
  29. uses: actions/cache@v2
  30. with:
  31. path: node_modules
  32. key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('./yarn.lock') }}
  33. - name: Get yarn cache dir
  34. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  35. id: cache-yarn
  36. run: echo "::set-output name=dir::$(yarn cache dir)"
  37. - name: Cache/Restore yarn cache
  38. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  39. uses: actions/cache@v2
  40. with:
  41. path: ${{ steps.cache-yarn.outputs.dir }}
  42. key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('./yarn.lock') }}
  43. restore-keys: |
  44. ${{ runner.os }}-yarn-${{ matrix.node-version }}-
  45. - name: Install dependencies
  46. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  47. run: |
  48. yarn --frozen-lockfile
  49. - name: Print dependencies
  50. run: |
  51. echo -n "node " && node -v
  52. echo -n "npm " && npm -v
  53. yarn list --depth=0
  54. - name: yarn lint
  55. run: |
  56. yarn test
  57. - name: Slack Notification
  58. uses: weseek/ghaction-slack-notification@master
  59. if: failure()
  60. with:
  61. type: ${{ job.status }}
  62. job_name: '*Node CI for growi-bot-proxy - test (${{ matrix.node-version }})*'
  63. channel: '#ci'
  64. isCompactMode: true
  65. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  66. launch-dev:
  67. runs-on: ubuntu-latest
  68. strategy:
  69. matrix:
  70. node-version: [14.x]
  71. services:
  72. mysql:
  73. image: mysql:8.0
  74. ports:
  75. - 3306
  76. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  77. env:
  78. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  79. MYSQL_DATABASE: growi-slackbot-proxy
  80. steps:
  81. - uses: actions/checkout@v2
  82. - name: Use Node.js ${{ matrix.node-version }}
  83. uses: actions/setup-node@v1
  84. with:
  85. node-version: ${{ matrix.node-version }}
  86. - name: Cache/Restore node_modules
  87. id: cache-dependencies
  88. uses: actions/cache@v2
  89. with:
  90. path: node_modules
  91. key: ${{ runner.OS }}-node_modules_dev-${{ matrix.node-version }}-${{ hashFiles('./yarn.lock') }}
  92. - name: Get yarn cache dir
  93. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  94. id: cache-yarn
  95. run: echo "::set-output name=dir::$(yarn cache dir)"
  96. - name: Cache/Restore yarn cache
  97. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  98. uses: actions/cache@v2
  99. with:
  100. path: ${{ steps.cache-yarn.outputs.dir }}
  101. key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
  102. restore-keys: |
  103. ${{ runner.os }}-yarn-
  104. - name: Install dependencies
  105. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  106. run: |
  107. yarn --frozen-lockfile
  108. - name: Print dependencies
  109. run: |
  110. echo -n "node " && node -v
  111. echo -n "npm " && npm -v
  112. yarn list --depth=0
  113. - name: yarn dev:ci
  114. run: |
  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. - 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 build
  188. - name: yarn install --production
  189. run: |
  190. 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. yarn start:prod:ci
  199. env:
  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. - name: Upload report as artifact
  206. uses: actions/upload-artifact@v2
  207. with:
  208. name: Report
  209. path: report
  210. - name: Slack Notification
  211. uses: weseek/ghaction-slack-notification@master
  212. if: failure()
  213. with:
  214. type: ${{ job.status }}
  215. job_name: '*Node CI for growi-bot-proxy - launch-prod (${{ matrix.node-version }})*'
  216. channel: '#ci'
  217. isCompactMode: true
  218. url: ${{ secrets.SLACK_WEBHOOK_URL }}