ljvmiranda921 / comments.ljvmiranda921.github.io

Blog comments for my personal blog: ljvmiranda921.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add badges to your Google Cloud Builds

ljvmiranda921 opened this issue · comments

Comment written by Joe Narvaez on 02/17/2019 05:47:58

I made my own badges and used python:

import base64
from google.cloud import storage
import json

client = storage.Client()
bucket = client.get_bucket('momentum-storage')
passing_blob = bucket.blob('passing.svg')
failing_blob = bucket.blob('failing.svg')


def status(data, context):
    string_data = base64.b64decode(data['data']).decode('utf-8')
    status = json.loads(string_data)['status']
    if status == 'SUCCESS' or status == 'QUEUED' or status == 'WORKING':
        bucket.copy_blob(passing_blob, bucket, 'status.svg')
    else:
        bucket.copy_blob(failing_blob, bucket, 'status.svg')