opa-coverage-badge

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README ¶

OPA Coverage Badge

👆 Easily create and insert coverage badge (or any other badge) in your readme with go

Using https://shields.io, the action will generate a coverage badge based on the OPA coverage output. The badge will be inserted on the second line of the readme if it doesn't exist, and will be updated if already present.

Flags

Flag Default Description
label Coverage Badge label
yellow-threshold 30 At what percentage the badge will become yellow instead of red
green-threshold 70 At what percentage the badge becomes green instead of yellow
color Force a color for the badge
target README.md Where to insert the badge

Examples

name: Test Coverage

on:
  push:
    branches: [main]
    
jobs:
  test-coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      
      - name: Setup opa
        uses: open-policy-agent/setup-opa@v1
        with:
          version: 0.34.1
      
      - name: Create OPA test coverage badge
        uses: oren-zohar/opa-coverage-badge
        with:
          label: OPA-Coverage # your badge label
          yellow-threshold: 50 # what percentage the badge will become yellow instead of red
          green-threshold: 80  # what percentage the badge becomes green instead of yellow 
          target: README.md # where to insert the badge

      - name: Verify Changed files
        uses: tj-actions/verify-changed-files@v8.1
        id: verify-changed-files
        with:
          files: README.md

      - name: Commit changes
        if: steps.verify-changed-files.outputs.files_changed == 'true'
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add README.md
          git commit -m "chore: Updated coverage badge."

      - name: Push changes
        if: steps.verify-changed-files.outputs.files_changed == 'true'
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ github.token }}
          branch: ${{ github.head_ref }}

Documentation ¶

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL