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