ci-slackbot-proxy.yml 7.3 KB

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