ci-slackbot-proxy.yml 7.3 KB

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