Giter Site home page Giter Site logo

jkff-mv / cloud-build-badge Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 24 KB

Google Cloud Build Badge Generator

License: MIT License

Python 100.00%
gcp google-cloud-platform cloud-functions google-cloud-functions cloud-build google-cloud-build python python3

cloud-build-badge's Introduction

Cloud Build Badge

latest version build status language license

Overview

Cloud Build のステータスを表すバッジを生成するアプリケーションです。

system overview

生成されるバッジはビルドのステータスに応じて6種類です。

  • ビルド中:working
  • ビルドの成功:success
  • ビルドの失敗:failure
  • ビルドのキャンセル:cancelled
  • ビルドのタイムアウト:timeout
  • ステップのタイムアウト:failed

Requirement

リポジトリの接続やCloud Buildの設定は済んでいることが前提となっています。
未設定の場合は 公式ドキュメント などを参考に設定してください。

なお、接続するリポジトリについてはCloud Source RepositoriesおよびGitHubにて正常に動作することを確認しています。

Setup

Create Bucket

バッジの保存先であるCloud Storageのバケットを作成します。

$ BUCKET_NAME='your-bucket-name'
$ gsutil mb -c standard -l us-central1 gs://${BUCKET_NAME}
$ gsutil iam ch allUsers:objectViewer gs://${BUCKET_NAME}

Deploy Function

バッジを生成するアプリケーションをCloud Functionsへデプロイします。

$ FUNCTION_NAME='any-function-name'
$ BUCKET_NAME='your-bucket-name'
$ gcloud functions deploy ${FUNCTION_NAME} \
  --runtime python38 \
  --entry-point entry_point \
  --trigger-topic cloud-builds \
  --region us-central1 \
  --set-env-vars _CLOUD_BUILD_BADGE_BUCKET=${BUCKET_NAME}

Usage

Generate Badge

Cloud Buildで実行される全てのビルドに対して自動でバッジが生成されます。

Badge Location

Cloud Buildのトリガの起動イベントが「ブランチへのpush」で対象のブランチが1つしか設定されていない場合、もしくはトリガの起動イベントが「タグのpush」の場合はこちらを参照ください。

https://storage.googleapis.com/<BUCKET>/triggers/<TRIGGER>/badge.svg

Cloud Buildのトリガの起動イベントが「ブランチへのpush」で対象のブランチが複数設定されている場合はこちらを参照ください。
なお、ビルドの構成ファイル自体の構文エラー等でビルドが失敗した場合、Cloud Functions内で対象のリポジトリ名/ブランチ名の情報が取得できず、バッジが更新されないため注意してください。

https://storage.googleapis.com/<BUCKET>/repositories/<REPOSITORY>/triggers/<TRIGGER>/branches/<BRANCH>/badge.svg
  • BUCKET :Cloud Storageのバケット名。
  • TRIGGER :Cloud BuildのトリガID。
  • REPOSITORY :ビルド対象のリポジトリ名。
  • BRANCH :ビルド対象のブランチ名。

Configuration

設定でバッジの生成を抑制したり、バッジのラベル部分を変更できます。
Cloud Functionsの環境変数、もしくはCloud Buildのトリガの代入変数に値を設定してください。
設定が重複している場合、Cloud Buildのトリガ側の設定値が優先されます。

Variable Type Required Default Description
_CLOUD_BUILD_BADGE_BUCKET string バッジの保存先となるCloud Storageのバケット名です。
_CLOUD_BUILD_BADGE_GENERATION string enabled バッジの生成に関する設定です。
enabled もしくは disabled を指定できます。
enabled の場合バッジを生成しバケットへ保存します。
disabled の場合バッジは生成されません。
_CLOUD_BUILD_BADGE_LABEL string build バッジのラベル部分に記載する文言です。
_CLOUD_BUILD_BADGE_LOGO string バッジのラベル部分に表示するロゴです。
Data URI形式の画像を指定できます。

cloud-build-badge's People

Contributors

jkff-mv avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.