ci-slackbot-proxy.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. name: Node CI for slackbot-proxy
  2. on:
  3. push:
  4. branches-ignore:
  5. - release/**
  6. - rc/**
  7. - support/prepare-v**
  8. paths:
  9. - .github/workflows/ci-slackbot-proxy.yml
  10. - .eslint*
  11. - tsconfig.base.json
  12. - yarn.lock
  13. - apps/slackbot-proxy/**
  14. - '!apps/slackbot-proxy/docker/**'
  15. - packages/slack/**
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.ref }}
  18. cancel-in-progress: true
  19. jobs:
  20. launch-dev:
  21. runs-on: ubuntu-latest
  22. strategy:
  23. matrix:
  24. node-version: [18.x]
  25. services:
  26. mysql:
  27. image: mysql:8.0
  28. ports:
  29. - 3306
  30. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  31. env:
  32. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  33. MYSQL_DATABASE: growi-slackbot-proxy
  34. steps:
  35. - uses: actions/checkout@v3
  36. - uses: actions/setup-node@v3
  37. with:
  38. node-version: ${{ matrix.node-version }}
  39. cache: 'yarn'
  40. cache-dependency-path: '**/yarn.lock'
  41. - name: Cache/Restore node_modules
  42. uses: actions/cache@v3
  43. with:
  44. path: |
  45. **/node_modules
  46. key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/app/package.json') }}
  47. restore-keys: |
  48. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
  49. node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
  50. - name: Cache/Restore dist and types
  51. uses: actions/cache@v3
  52. with:
  53. path: |
  54. **/dist
  55. **/types
  56. key: dist-ci-slackbot-proxy-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  57. restore-keys: |
  58. dist-ci-slackbot-proxy-${{ runner.OS }}-node${{ matrix.node-version }}-
  59. - name: Install dependencies
  60. run: |
  61. yarn global add turbo
  62. yarn --frozen-lockfile
  63. - name: yarn dev:ci
  64. working-directory: ./apps/slackbot-proxy
  65. run: |
  66. cp config/ci/.env.local.for-ci .env.development.local
  67. turbo run dev:ci
  68. env:
  69. SERVER_URI: http://localhost:8080
  70. TYPEORM_CONNECTION: mysql
  71. TYPEORM_HOST: localhost
  72. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  73. TYPEORM_DATABASE: growi-slackbot-proxy
  74. TYPEORM_USERNAME: root
  75. TYPEORM_PASSWORD:
  76. - name: Slack Notification
  77. uses: weseek/ghaction-slack-notification@master
  78. if: failure()
  79. with:
  80. type: ${{ job.status }}
  81. job_name: '*Node CI for growi-bot-proxy - launch-dev (${{ matrix.node-version }})*'
  82. channel: '#ci'
  83. isCompactMode: true
  84. url: ${{ secrets.SLACK_WEBHOOK_URL }}
  85. launch-prod:
  86. runs-on: ubuntu-latest
  87. strategy:
  88. matrix:
  89. node-version: [18.x]
  90. services:
  91. mysql:
  92. image: mysql:8.0
  93. ports:
  94. - 3306
  95. options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 3
  96. env:
  97. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  98. MYSQL_DATABASE: growi-slackbot-proxy
  99. steps:
  100. - uses: actions/checkout@v3
  101. - uses: actions/setup-node@v3
  102. with:
  103. node-version: ${{ matrix.node-version }}
  104. cache: 'yarn'
  105. cache-dependency-path: '**/yarn.lock'
  106. - name: Install turbo
  107. run: |
  108. yarn global add turbo
  109. - name: Prune repositories
  110. run: |
  111. turbo prune --scope=@growi/slackbot-proxy
  112. rm -rf apps packages
  113. mv out/* .
  114. - name: Cache/Restore node_modules
  115. id: cache-dependencies
  116. uses: actions/cache@v3
  117. with:
  118. path: |
  119. **/node_modules
  120. key: node_modules-slackbot-prxy-build-prod-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
  121. restore-keys: |
  122. node_modules-slackbot-proxy-build-prod-${{ runner.OS }}-node${{ inputs.node-version }}-
  123. - name: Install dependencies
  124. run: |
  125. yarn --frozen-lockfile
  126. - name: Cache/Restore dist and types
  127. uses: actions/cache@v3
  128. with:
  129. path: |
  130. **/dist
  131. **/types
  132. key: dist-slackbot-proxy-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
  133. restore-keys: |
  134. dist-slackbot-proxy-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
  135. - name: Build
  136. working-directory: ./apps/slackbot-proxy
  137. run: |
  138. turbo run build
  139. - name: Install dependencies for production
  140. run: |
  141. yarn --production
  142. - name: yarn start:prod:ci
  143. working-directory: ./apps/slackbot-proxy
  144. run: |
  145. cp config/ci/.env.local.for-ci .env.production.local
  146. yarn start:prod:ci
  147. env:
  148. SERVER_URI: http://localhost:8080
  149. TYPEORM_CONNECTION: mysql
  150. TYPEORM_HOST: localhost
  151. TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
  152. TYPEORM_DATABASE: growi-slackbot-proxy
  153. TYPEORM_USERNAME: root
  154. TYPEORM_PASSWORD:
  155. - name: Slack Notification
  156. uses: weseek/ghaction-slack-notification@master
  157. if: failure()
  158. with:
  159. type: ${{ job.status }}
  160. job_name: '*Node CI for growi-bot-proxy - launch-prod (${{ matrix.node-version }})*'
  161. channel: '#ci'
  162. isCompactMode: true
  163. url: ${{ secrets.SLACK_WEBHOOK_URL }}