Skip to content

Instantly share code, notes, and snippets.

@jay-snee
Created March 11, 2020 20:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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/postgresql-action@v1.0.0
with:
postgresql user: test
postgresql password: password
- name: Set up Redis
uses: zhulik/redis-action@1.1.0
- 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/merge-branch@v1.1.0
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