Skip to content

Instantly share code, notes, and snippets.

@jay-snee
Created March 11, 2020 20:03
Show Gist options
  • Save jay-snee/b37a2eee166d83598400d79a49e71bfb to your computer and use it in GitHub Desktop.
Save jay-snee/b37a2eee166d83598400d79a49e71bfb to your computer and use it in GitHub Desktop.
GitHub Actions workflow to install Ruby/Redis/Postgresql, build a Ruby app (with gem cache) and then run then Rspec with final step to merge onto 'deploy' branch upon successful completion.
name: run rspec
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Set up PostgreSQL
uses: Harmon758/[email protected]
with:
postgresql user: test
postgresql password: password
- name: Set up Redis
uses: zhulik/[email protected]
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Build app
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundle exec rails db:setup RAILS_ENV=test
env:
DATABASE_URL: 'postgres://test:password@localhost/application_test'
- name: Run specs
run: |
bundle exec rspec
env:
DATABASE_URL: 'postgres://test:password@localhost/application_test'
- name: Merge to deploy branch
uses: devmasx/[email protected]
with:
type: now
target_branch: 'deploy'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment