New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cloud-build-badge

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloud-build-badge

A cloud function that changes GitHub badges depending on Cloud Build status. Forked from sbsends/cloud-build-badge

  • 1.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

cloud-build-badge

npm version License

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.

  1. Ensure that you have the Google Cloud SDK installed in your system.
  2. In your project, create a Google Cloud Storage bucket (referred to as ${BUCKET}), and make a folder named build.
  3. 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).
  4. Install cloud-build-badge via npm:
$ 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

  1. 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.

  1. 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
  1. 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)

Keywords

FAQs

Package last updated on 04 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc