ci-slackbot-proxy.yml 7.3 KB

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