Migrate Travis CI to GitHub Actions for Ruby

Feb 23 · 2 min read
GitHub Actions and Ruby
GitHub Actions + Ruby

This article goes over how to migrate from Travis CI to GitHub Actions for a Ruby project on GitHub.

Watch the YouTube video:

Travis CI

Given the .travis.yml:

GitHub Actions

First make the directory .github/workflows/:

mkdir -p .github/workflows/

Create .github/workflows/build.yml:

touch .github/workflows/build.yml

Add the workflow that runs a single job:

To test multiple versions of Ruby, update the workflow:

The Ruby workflow is inspired by the template.


Here’s a breakdown of what each YAML field does.

name is the workflow name. It’s optional and you can name it whatever you like:

on is the event that triggers the workflow. In our example, git push triggers our workflow.

To add the pull_request event:

Which is the same thing as:

jobs are the jobs that the workflow runs. In our example, we have a single job named build:

runs-on is the environment that the workflow runs on. To specify an OS version:

strategy.matrix is the build matrix. In our example, we’re running a job for a single ruby version. To define jobs for multiple ruby versions:

steps are the tasks of a job. In our example, we’re using the GitHub Actions:

actions/checkout checks out the repository and ruby/setup-ruby sets up the Ruby environment:

steps.run runs the commands. Since setup-ruby installs bundler, it can be used to execute commands:

env sets the environment variables for the entire workflow or an individual step. See env and jobs.<job_id>.steps.env.

Although Travis CI sets default environment variables, we don’t have to set CI=true for our job since actions/checkout@v2 does it for us:


Geek Culture

Proud to geek out.

By Geek Culture

Subscribe to receive top 10 most read stories of Geek Culture — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).


Written by


Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store