sunakan / notes-about-circleci

MIT License
0 stars 0 forks source link

Helloworld orbの自作トライ #5

Open sunakan opened 5 years ago

sunakan commented 5 years ago

ゴール:自分でアップロードしたhelloworld orbを使い、結果がsuccess

sunakan commented 5 years ago

キャプチャ

sunakan commented 5 years ago

circle-cliのインストール

circleci update install でアップデート

sunakan commented 5 years ago

手元でのアプデの様子

$ sudo circleci update install
You are running 0.1.5389
A new release is available (0.1.5490)
Updated to 0.1.5490
sunakan commented 5 years ago

sudo付ける必要があるかどうかはインストールされてる環境次第かと

sunakan commented 5 years ago

orb専用のリポジトリを用意

sunakan commented 5 years ago

https://circleci.com/account/api

でcliのPersonal API Tokenの発行

sunakan commented 5 years ago

circleci setupでAPIをセットアップ

様子

$ sudo circleci setup
✔ CircleCI API Token: **█

✔ CircleCI API Token: ****************************************

✔ CircleCI Host: https://circleci.com
CircleCI host has been set.
Setup complete.
Trying an introspection query on API to verify your setup... Ok..yml.
Trying to query your username given the provided token... Hello, Sunakan.
sunakan commented 5 years ago

はじめのはミス

sunakan commented 5 years ago

circleci namespace create <任意の Orb のネームスペース> <VCS プロパイダ名> <CircleCI のオーガニゼーション名>

$ sudo circleci namespace create sunakan github sunakan
You are creating a namespace called "sunakan".

This is the only namespace permitted for your github organization, sunakan.

To change the namespace, you will have to contact CircleCI customer support.

✔ Are you sure you wish to create the namespace: `sunakan`: y
Namespace `sunakan` created.
Please note that any orbs you publish in this namespace are open orbs and are world-readable.

ネームスペースは今のうちとっておけ感?

sunakan commented 5 years ago

1namespace1リポジトリ? 1namespaceNorbs? 1リポジトリの全てのOrb?

sunakan commented 5 years ago

circleci orb publish orb.yml <Orb のネームスペース>/<任意の Orb 名>@<任意の Orb のバージョン>

エラーーーー

$ sudo circleci orb publish src/hello-world/orb.yml sunakan/hello-world@dev:test-branch
Error: the 'hello-world' orb does not exist in the 'sunakan' namespace. Did you misspell the namespace or the orb name?
sunakan commented 5 years ago

1度createするって公式にあった https://circleci.com/docs/2.0/creating-orbs/#section=configuration

$ sudo circleci orb create sunakan/hello-world
You are creating an orb called "sunakan/hello-world".

You will not be able to change the name of this orb.

If you change your mind about the name, you will have to create a new orb with the new name.

✔ Are you sure you wish to create the orb: `sunakan/hello-world`: y
Orb `sunakan/hello-world` created.
Please note that any versions you publish of this orb are world-readable.
You can now register versions of `sunakan/hello-world` using `circleci orb publish`.
sunakan commented 5 years ago

シンタックスチェックもできる!

$ sudo circleci orb validate src/hello-world/orb.yml
Error: ERROR IN CONFIG FILE:
[#/version] Input not a valid enum value
  enum:
  - '2.1'
  - 2.1
sunakan commented 5 years ago

orb.ymlの中に書くバージョンはCircleCIのバージョンだった

sunakan commented 5 years ago

このときでは2.1

sunakan commented 5 years ago

release done

$ sudo circleci orb publish src/hello-world/orb.yml sunakan/hello-world@dev:test-branch
Orb `sunakan/hello-world@dev:test-branch` was published.
Please note that this is an open orb and is world-readable.
Note that your dev label `dev:test-branch` can be overwritten by anyone in your organization.
Your dev orb will expire in 90 days unless a new version is published on the label `dev:test-branch`.
sunakan commented 5 years ago

devタグでやってるため90日間放置で消える! 最高!!

sunakan commented 5 years ago

devタグだと多分 https://circleci.com/orbs/registry/?query=&filterBy=all に出てこないかもしれない

sunakan commented 5 years ago

version 0.0.1でリリース

$ sudo circleci orb publish src/hello-world/orb.yml sunakan/hello-world@0.0.1
Orb `sunakan/hello-world@0.0.1` was published.
Please note that this is an open orb and is world-readable.
sunakan commented 5 years ago

キャプチャ

sunakan commented 5 years ago

commandを一つも書いていないので、書いて再公開する

sunakan commented 5 years ago

orb便利かも

Discordの送信方法や、slack、codecoverageの送り方などが変わった時、1つのorbの変更で対応できそうherokuとかも

Tokenだけ環境変数にして、orb切り替えでリポジトリにまたがって適応されるだろうし、orbのバージョン指定で、特定の挙動とかも特定のサービス、特定のデプロイ方法、特定のビルド方法とか指定できそう

sunakan commented 5 years ago

この方のが参考になるかも 今日誕生日のアイマスアイドルだすやつ

yutagoto/todays-imas-idol@1.0.0

https://circleci.com/orbs/registry/orb/yutagoto/todays-imas-idol