Hack Your Design!

はじめてのCircleCI Orbsを公開した

(image)はじめてのCircleCI Orbsを公開した

はじめてのCircleCI Orbsを公開した。そのメモ。

CircleCI Orbsとは

2018年11月に正式公開されたCircleCI Orbs。

要はいろんなレポジトリで使っている共通のCircleCIの設定を共通化できる仕組みのこと。

作ってみた

僕もいろんなRuby on Railsプロジェクトでよく使うコマンド、bundle installをCircleCI Orbsを使って共通化してみることにしてみました。

作り方

Install circleci command

まずはcircleciコマンドを入手。MacOSの場合下記のようにbrewで入れることができます。

brew install circleci

namespace 作成

namespaceを取得します。

$ circleci namespace create toshimaru github toshimaru

Orb 作成

namespace以下のorb名を作成します。

$ circleci orb create toshimaru/bundle-install
Orb toshimaru/bundle-install created.
Please note that any versions you publish of this orb are world-readable.

You can now register versions of toshimaru/bundle-install using circleci orb publish.

Publish CircleCI Orb

作成したorb.ymlを公開します。

$ circleci orb publish src/orb.yml toshimaru/bundle-install@0.0.1
Orb toshimaru/bundle-install@0.0.1 was published.
Please note that this is an open orb and is world-readable.

作成したOrbを使う

次に作成したOrbを使う側、呼び出す側の設定です。

orbs:
  bundle-install: toshimaru/bundle-install@0.1.0
jobs:
  build:
    docker:
      - image: circleci/ruby
    steps:
      - checkout
      - bundle-install/bundle-install
      # - bundle exec rspec

実際に下記のPRでOrbの変更例が見れますのでご参照ください。

Introduce CircleCI Orbs by toshimaru · Pull Request #264

参考にした記事

  • 全体的にこちらの手順を参考にさせていただきました。 CircleCI Orbs 入門 | tsub’s blog
  • ファイルの構成などこちらを参考にさせていただきました。https://github.com/sue445/circleci-ruby-orbs
  • このエントリーをはてなブックマークに追加