cloud-build-badge
v1.4.1
Published
A cloud function that changes GitHub badges depending on Cloud Build status. Forked from sbsends/cloud-build-badge
Downloads
53
Maintainers
Readme
cloud-build-badge
Automate the creation of Google Cloud Build badges for your project! Cloud builds in the Google Cloud Platform are fun, but unlike Travis, Circle-CI, and AppVeyor, it doesn't provide badges out-of-the-box. This small script aims to provide a solution.
(This is a fork of
sbsends/cloud-build-badge that
solves the same problem using sed
commands and environment variables. My aim
is to provide a more "JS-native" solution)
I also wrote a blog post tutorial for creating Cloud Build badges. Read it here
Setup
The first three steps ensure that we have the required badges in our project's cloud storage. The last step simply install this package in your system.
- Ensure that you have the Google Cloud SDK installed in your system.
- In your project, create a Google Cloud Storage bucket (referred to as
${BUCKET}
), and make a folder namedbuild
. - Inside
build/
, save an SVG copy of the SUCCESS and FAILURE badges. You can create your own here, or you can just copy and save from here (success, failure). - Install
cloud-build-badge
vianpm
:
$ npm install cloud-build-badge
Deploy
It only takes three steps to start deploying your cloud badges! First we create
the deploy script, then we call gcloud functions
to send it over to GCP, then
we put the resulting badge in our project's README
- Run
cloud-build-badge
and supply the following arguments:
--id deploy function unique ID
--repository target repository name
--branches target branches, e.g. master, development
--bucket name of bucket, e.g. ${BUCKET}
For example,
cloud-build-badge \
--id myFunction \
--repository my-repository \
--branches master development \ # You can supply multiple values
--bucket my-project-bucket
This will generate a JS file (default is function.js
) that
contains the deploy function that we'll need.
- Copy the resulting command to deploy via
gcloud functions
. As reference, here's what it looks like:
gcloud functions deploy <ID> \
--runtime nodejs6 \
--trigger-resource cloud-builds \
--trigger-event google.pubsub.topic.publish
- You'll find the resulting badge saved inside your project's GCS bucket! You can then use it for your README's badge! This badge, through Cloud Functions, will change depending on the status of your latest build.
[![cloud build status](https://storage.googleapis.com/<BUCKET>/build/<REPOSITORY>-<BADGE>.svg)](https://github.com/ljvmiranda921/cloud-build-badge)