Merge pull request #1494 from 8398a7/develop #294
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-24.04 | |
env: | |
RAILS_ENV: test | |
TZ: /usr/share/zoneinfo/Asia/Tokyo | |
SECRET_KEY_BASE: 359471d5e4c02070d08ca9f880c110e197fdf8a60222da9dce663813fdd80f0d3eeeacd9098174aaad2008614b917896856fac275e31993283672288b0520731 | |
RETRY_RSPEC: 3 | |
IIDX_VERSION: 27 | |
services: | |
postgres: | |
image: postgres:17.0-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
redis: | |
image: redis:7.4.1-alpine | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: yarn | |
- run: yarn install --frozen-lockfile | |
- name: Run Eslint and Prettier | |
run: yarn lint | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.3.5 | |
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}} | |
NODE_OPTIONS: --openssl-legacy-provider | |
with: | |
coverageCommand: bundle exec rspec | |
- name: Archive artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./tmp/test-results | |
build: | |
if: contains(github.ref, 'master') | |
runs-on: ubuntu-24.04 | |
needs: [test] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Get short SHA | |
id: vars | |
run: echo "SHA_TAG=$(git describe --tags --abbrev=10)" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: login ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: 8398a7 | |
password: ${{ secrets.REGISTRY_TOKEN }} | |
- name: build image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/8398a7/abilitysheet/app:${{ env.SHA_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- uses: actions/delete-package-versions@v5 | |
with: | |
package-name: abilitysheet/app | |
package-type: container | |
min-versions-to-keep: 9 | |
- 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-24.04 | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: deploy abilitysheet | |
run: | | |
curl -X POST \ | |
https://api.github.com/repos/8398a7/iidx-app-cluster/actions/workflows/deploy.yml/dispatches \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
-H "Authorization: Basic ${{ secrets.DEPLOY_TOKEN }}" \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"ref\": \"master\", \"inputs\": {\"role\": \"abilitysheet\", \"image_tag\": \"$(git describe --tags --abbrev=10)\"}}" |