-
-
Save diogowernik/bb9fbffd4acc7ed230629302a1f2d576 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.
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: 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