Skip to content

Commit

Permalink
Switch from Travis CI to GitHub Actions (#27)
Browse files Browse the repository at this point in the history
* Try installing a few deps

* Install Node, Ruby, and attach a Postgres instance

* Match the installed version of ruby with the one in ruby-version

* Use a clever method for finding the current ruby version

actions/setup-ruby#31 (comment)

* Oops, gotta checkout the code before reading the version

* Bump to the latest patch version of Ruby

* Bump the Gemfile too

* Health check the Postgres instance and split out the bundle step

* use the latest Postgres, reformat the heallth check

* Point Rails at the service container

* Switch back to port mapping postgres to the local machine

* Manually set up the postgres instance and use DATABASE_URL for telling Rails where to look

* Deploy using GitHub workflows

* Use secrets store

* Setup both api. and git. for Heroku

* Specify the Heroku app to deploy to

* Double check current config

* debug heroku auth

* Work that netrc

* try and preserve newlines when writing netrc

* Be extra specific with the GH branch we want to push

* Only deploy on master

* I read the docs

* Install specific node versions

* Cache Node Modules runs

* Cache Ruby dependencies

* Ditch Travis
  • Loading branch information
waltz committed Mar 1, 2020
1 parent 1a54914 commit 5196fec
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 27 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
on: [push]
jobs:
build:
name: Test
runs-on: ubuntu-latest

services:
postgres:
image: postgres
ports: ['5432:5432']
env:
POSTGRES_USER: test-a-bot
POSTGRES_PASSWORD: toot
POSTGRES_DATABASE: rubbish-heap

steps:
- name: Get Code
uses: actions/checkout@v2

- name: Install Dependencies
run: |
sudo apt-get install ffmpeg -y
sudo apt-get install youtube-dl
- name: Fetch Ruby Version
id: ruby_version
run: echo "::set-output name=RUBY_VERSION::$(cat .ruby-version)"

- name: Install Ruby
uses: actions/setup-ruby/@v1
with:
ruby-version: ${{ steps.ruby_version.outputs.RUBY_VERSION }}

- name: Fetch Node Version
id: node_version
run: echo "::set-output name=NODE_VERSION::$(cat .nvmrc)"

- name: Install Node
uses: actions/setup-node@v1
with:
node-version: ${{ steps.node_version.outputs.NODE_VERSION }}

- name: Fetch Yarn Cache Directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Configure Yarn Cache
uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node Packages
run: yarn

- name: Configure Ruby Cache
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Ruby Packages
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Build and Test with Rake
env:
DATABASE_URL: postgres://test-a-bot:toot@localhost/rubbish-heap
RAILS_ENV: test
run: |
bundle exec rails db:setup
bundle exec rails test
- name: Write Heroku Credentials
env:
NETRC: |
machine api.heroku.com
login ${{ secrets.HEROKU_USER }}
password ${{ secrets.HEROKU_API_KEY }}
machine git.heroku.com
login ${{ secrets.HEROKU_USER }}
password ${{ secrets.HEROKU_API_KEY }}
run: echo $NETRC > ~/.netrc

- name: Push to Heroku
if: github.ref == 'master'
run: |
heroku git:remote --app imploder-staging
git push heroku HEAD:master
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.3
2.6.5
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '2.6.3'
ruby '2.6.5'

gem 'rails', '5.2.3'

Expand Down

0 comments on commit 5196fec

Please sign in to comment.