ci-slackbot-proxy.yml 5.4 KB

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