Skip to content

Instantly share code, notes, and snippets.

@anaschwendler
Created December 6, 2019 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaschwendler/15e9ec9aaa02dfe19a6229a3b16573e5 to your computer and use it in GitHub Desktop.
Save anaschwendler/15e9ec9aaa02dfe19a6229a3b16573e5 to your computer and use it in GitHub Desktop.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
container:
image: ruby:2.6.5
services:
<db_service_name>:
image: postgres:10.6
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@master
- uses: actions/cache@v1
with:
path: /usr/local/bundle
key: v1-gem-cache-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: v1-gem-cache
- name: Install dependencies
env:
BUNDLE_GITHUB__COM: ${{ secrets.BUNDLE_GITHUB__COM }}:x-oauth-basic
run: "make deps"
- name: Lint
run: "make lint"
- name: Test
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
RAILS_ENV: "test"
DATABASE_URL: "postgres://postgres@<db_service_name>:5432/<db_name>"
run: "make test"
deploy:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
needs: test
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
steps:
- uses: actions/checkout@master
- name: Build Docker image
env:
BUNDLE_GITHUB__COM: ${{ secrets.BUNDLE_GITHUB__COM }}:x-oauth-basic
run: "make build"
- name: Deploy to staging
if: github.ref == 'refs/heads/staging'
run: DEPLOYER=${GITHUB_ACTOR} make deploy_to_staging
- name: Deploy to production
if: github.ref == 'refs/heads/master'
run: DEPLOYER=${GITHUB_ACTOR} make deploy_to_production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment