Merge pull request #1489 from 8398a7/develop #263
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
RAILS_ENV: test | |
TZ: /usr/share/zoneinfo/Asia/Tokyo | |
SECRET_KEY_BASE: 359471d5e4c02070d08ca9f880c110e197fdf8a60222da9dce663813fdd80f0d3eeeacd9098174aaad2008614b917896856fac275e31993283672288b0520731 | |
RETRY_RSPEC: 3 | |
IIDX_VERSION: 27 | |
services: | |
postgres: | |
image: postgres:11.5-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
redis: | |
image: redis:5.0.5-alpine | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v3 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn-v1 | |
- name: yarn install | |
run: yarn install | |
- name: Run Eslint and Prettier | |
run: yarn lint | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1.2 | |
bundler-cache: true | |
- name: Install PostgreSQL | |
run: sudo apt-get -yqq install libpq-dev | |
- name: Setup Application Environment | |
run: | | |
mv .env.sample .env | |
mkdir -p tmp/test-results | |
mv config/database.ci.yml config/database.yml | |
bundle exec rails ts:routes | |
- name: Create and Migrate Database | |
run: bundle exec rails db:create db:migrate | |
- name: Run Rubocop | |
run: bundle exec bin/rubocop_parallel | |
- name: Run rspec and Publish code coverage | |
uses: paambaati/codeclimate-action@v3.0.0 | |
env: | |
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} | |
with: | |
coverageCommand: bundle exec rspec | |
- name: Archive artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ./tmp/test-results | |
build: | |
if: contains(github.ref, 'master') | |
runs-on: ubuntu-latest | |
needs: [test] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: docker login | |
run: echo $REGISTRY_TOKEN | docker login docker.pkg.github.com -u 8398a7 --password-stdin | |
env: | |
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} | |
- run: make pull build | |
- name: initialize gcloud sdk | |
run: | | |
echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json | |
gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json | |
gcloud --quiet config set project iidx-app | |
gcloud --quiet config set compute/zone us-west1-b | |
gcloud auth configure-docker --quiet --project iidx-app | |
env: | |
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} | |
- run: make push | |
- uses: 8398a7/action-slack@v3 | |
with: | |
fields: repo,job | |
status: ${{ job.status }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: always() | |
deploy: | |
if: contains(github.ref, 'master') | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: deploy abilitysheet chart | |
run: | | |
curl -X POST \ | |
https://api.github.com/repos/8398a7/iidx-app-cluster/dispatches \ | |
-H 'Accept: application/vnd.github.everest-preview+json' \ | |
-H "Authorization: Basic ${TOKEN}" \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"event_type\": \"abilitysheet abilitysheet.image.tag=$(git describe --tags --abbrev=10)\"}" | |
env: | |
TOKEN: ${{ secrets.DEPLOY_TOKEN }} |