Skip to content

Instantly share code, notes, and snippets.

@JuanitoFatas
Last active February 26, 2020 07:32
Show Gist options
  • Save JuanitoFatas/099f9d0d2f836d183528304dff6dce32 to your computer and use it in GitHub Desktop.
Save JuanitoFatas/099f9d0d2f836d183528304dff6dce32 to your computer and use it in GitHub Desktop.
Example GitHub Actions configurations for a Rails app
# .github/workflows/build.yml
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
services:
postgres:
image: postgres:12.0
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
ports:
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: apt-get
run: |
sudo apt-get update -y
sudo apt-get install -y libpq-dev postgresql-client
- name: Set up Redis
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: '5.x'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Cache gems
uses: actions/cache@v1
with:
path: vendor/bundle
key: bundle-use-ruby-${{ runner.os }}-${{ hashFiles('.ruby-version') }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
bundle-use-ruby-${{ runner.os }}-${{ hashFiles('.ruby-version') }}-
- name: bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Get Yarn cache directory
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache node modules
id: yarn-cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-js-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-js-
- name: yarn install
run: yarn install --dev
- name: Setup database
run: bin/rails db:create db:migrate
- name: RSpec
run: bin/rspec
- name: Rubocop
run: bin/rubocop --parallel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment