← Back to Use Cases
SCHEDULED JOBS & PIPELINES

Build Badge Data

Store pass/fail status for your README badges. Update from CI, read from anywhere.

The Problem

You want a build status badge in your README, but you're not using a major CI platform with built-in badges. Or you want custom metrics beyond just "passing/failing".

Services like shields.io can fetch data from URLs, but you need somewhere to store the status first.

The WrenDB Solution

Store badge status in WrenDB from your CI pipeline. Use shields.io's endpoint badge to display it in your README.

Complete Example

1

Create a stash for your project

Terminal
curl -X POST https://wrendb.com/api/stash

# Save these as GitHub secrets:
# WREN_STASH_ID and WREN_TOKEN
2

Update status from CI

.github/workflows/test.yml
name: Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: npm test

      # Update badge status
      - name: Update build badge
        if: always()
        run: |
          if [ "${{ job.status }}" == "success" ]; then
            STATUS="passing"
            COLOR="brightgreen"
          else
            STATUS="failing"
            COLOR="red"
          fi

          # Store badge data as JSON
          curl -X PUT https://wrendb.com/api/item/${{ secrets.WREN_STASH_ID }}/build-status \
            -H "Authorization: Bearer ${{ secrets.WREN_TOKEN }}" \
            -H "Content-Type: application/json" \
            -d "{
              \"schemaVersion\": 1,
              \"label\": \"build\",
              \"message\": \"$STATUS\",
              \"color\": \"$COLOR\"
            }"
3

Add badge to README

README.md
# My Project

![Build Status](https://img.shields.io/endpoint?url=https://wrendb.com/api/item/YOUR_STASH_ID/build-status)

Your project description here...

The badge will automatically update whenever your CI runs!

Custom Metrics Badge

Track custom metrics like test coverage, performance scores, or deployment count:

Update coverage badge
# Extract coverage from your test output
COVERAGE=$(npm test -- --coverage | grep "All files" | awk '{print $10}')

# Determine color based on coverage
if [ ${COVERAGE%.*} -ge 80 ]; then
  COLOR="brightgreen"
elif [ ${COVERAGE%.*} -ge 60 ]; then
  COLOR="yellow"
else
  COLOR="red"
fi

# Update WrenDB
curl -X PUT https://wrendb.com/api/item/$WREN_STASH_ID/coverage \
  -H "Authorization: Bearer $WREN_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"schemaVersion\": 1,
    \"label\": \"coverage\",
    \"message\": \"${COVERAGE}\",
    \"color\": \"$COLOR\"
  }"
README.md
![Coverage](https://img.shields.io/endpoint?url=https://wrendb.com/api/item/YOUR_STASH_ID/coverage)

Why This Works

  • No badge service account needed - Just store JSON, shields.io does the rest
  • Works with any CI - If it can curl, it can update badges
  • Custom metrics - Track anything you want: coverage, perf scores, deploy count
  • Always up-to-date - Badges refresh automatically from WrenDB

Badge JSON Format

Shields.io expects this JSON structure:

Badge format
{
  "schemaVersion": 1,
  "label": "build",          // Left side text
  "message": "passing",      // Right side text
  "color": "brightgreen"   // Badge color
}

Colors: brightgreen, green, yellow, orange, red, blue, lightgrey

Related Use Cases

CI/CD State - Pass data between pipeline stages Cron Memories - Store state between runs