Skip to main content
The Deno 2 Release Candidate is here
Learn more

Ruby Pipeline

deno module deno compatibility

A ready-to-use GitLab CI Pipeline and Jobs for Ruby projects.

🚀 Usage

Quick start:

import { GitLab } from "https://deno.land/x/ruby_pipeline/mod.ts";

const { pipeline } = GitLab;

pipeline.write(); // Write the pipeline to the file .gitlab-ci.yml

Or, if you want to use the predefined jobs:

import { GitlabCI } from "https://deno.land/x/fluent_gitlab_ci@v0.3.2/mod.ts";
import { GitLab } from "https://deno.land/x/ruby_pipeline/mod.ts";

const { herokuDeploy, rails, rspec, rubocop } = GitLab;

const gitlabci = new GitlabCI()
  .image("ruby:latest")
  .services(["mysql:latest", "redis:latest", "postgres:latest"])
  .variables({
    POSTGRES_DB: "database_name",
  })
  .cache(["vendor/ruby"])
  .beforeScript(
    `
  ruby -v
  bundle config set --local deployment true 
  bundle install -j $(nproc)
`
  )
  .addJob("rubocop", rubocop)
  .addJob("rails", rails)
  .addJob("rspec", rspec)
  .addJob("hreoku_deploy", herokuDeploy);

pipeline.write(); // Write the pipeline to the file .gitlab-ci.yml

It will generate the following .gitlab-ci.yml file:

# Do not edit this file directly. It is generated by Fluent GitLab CI

image: ruby:latest

services:
  - mysql:latest
  - redis:latest
  - postgres:latest

variables:
  POSTGRES_DB: database_name

cache:
  paths:
    - vendor/ruby

before_script:
  - ruby -v
  - bundle config set --local deployment true
  - bundle install -j $(nproc)

rubocop:
  script:
    - rubocop

rails:
  variables:
    DATABASE_URL: postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB
  script:
    - rails db:migrate
    - rails db:seed
    - rails test

rspec:
  script:
    - rspec spec

hreoku_deploy:
  stage: deploy
  environment: production
  script:
    - gem install dpl
    - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_PRODUCTION_KEY