Skip to content

samsends/cloud-build-badge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloud-build-badge

Add cloud build badges in 2 minutes.

  1. Create a cloud storage bucket (tutorial here).
  2. Create a folder in the bucket named build.
  3. Download failure and success badges (follow links and save).
  4. Upload both badges to the google storage bucket/folder created in the previous step (e.g. YOUR_BUCKET/build/success.svg).
  5. Create a placeholder for your badge (e.g. YOUR_BUCKET/build/BADGE_ID.svg (make permissions public).
  6. Set ENV Variables.
export REPO="YOUR_REPO" // e.g. github_sbsends_cloud_build_badge
export BRANCH="YOUR_BRANCH" // e.g. master
export BUCKET="YOUR_BUCKET" // e.g. my-gcp-bucket
export BADGE="PATH_TO_PUBLIC_BADGE" // e.g. cbb-master-badge
  1. Clone this repository into any directory.

git clone https://github.com/sbsends/cloud-build-badge.git

cd cloud-build-badge

  1. Use regular expressions to alter the index.js file (the cloud function).

sed -i.tmp -e "s/\${repo}/$REPO/" -e "s/\${branch}/$BRANCH/" -e "s/\${bucket}/$BUCKET/" -e "s/\${badge}/$BADGE/" index.js && rm index.js.tmp

  1. Deploy the cloud function as the badge name and set the function trigger to the cloud-builds pubsub topic.

gcloud functions deploy $BADGE --runtime nodejs6 --trigger-resource cloud-builds --trigger-event google.pubsub.topic.publish

  1. Add badge to README.md
# README.md
[![cloud build status](https://storage.googleapis.com/<BUCKET>/build/<BADGE>.svg)](https://github.com/sbsends/cloud-build-badge)

About

Add GitHub badges to your Google cloud builds!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published