リリース #38
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: cicd | |
on: | |
pull_request: | |
branches: | |
- main | |
env: | |
RUBY_VERSION: 3.3.0 | |
NODE_VERSION: 18.12.1 | |
RAILS_ENV: test | |
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" | |
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
jobs: | |
test_and_check: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
services: | |
postgres: | |
image: postgres:14 | |
ports: | |
- "5432:5432" | |
env: | |
POSTGRES_DB: rails_test | |
POSTGRES_USER: rails | |
POSTGRES_PASSWORD: password | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v3 | |
- name: Install Ruby and gems | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ env.RUBY_VERSION }} | |
bundler-cache: true | |
- name: Install Bundler | |
run: gem install bundler --no-document -v $(grep "BUNDLED WITH" -1 Gemfile.lock | tail -n 1) | |
- name: Bundle install | |
run: | | |
bundle config set --local path 'vendor/bundle' | |
bundle install --jobs 4 --retry 3 | |
- name: DB setup | |
run: bundle exec rails db:setup | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Yarn install | |
run: yarn install --check-files | |
- name: libvips install | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libvips | |
- name: Assets Precompile | |
run: bundle exec rake assets:precompile | |
- name: Run rubocop | |
run: bundle exec rubocop | |
- name: Run ESlint | |
run: yarn run lint:eslint | |
- name: Run Prettier | |
run: yarn run lint:prettier | |
- name: Run tests | |
run: bin/rails test test/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test_and_check | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- run: flyctl deploy --remote-only --build-arg RAILS_MASTER_KEY=${{ env.RAILS_MASTER_KEY }} | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |