-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
action.yml
74 lines (64 loc) · 2.13 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Go Coverage Badge
description: Generate coverage badge for go projects
author: tj-actions
inputs:
filename:
description: 'File containing the tests output'
required: true
default: coverage.out
color:
description: 'Color of the badge - green/yellow/red'
required: false
green:
description: 'At what percentage does the badge become green instead of yellow (default: 70)'
required: false
target:
description: 'Target file (default "README.md")'
required: false
text:
description: 'Text on the left side of the badge (default: "Coverage")'
required: false
value:
description: 'Text on the right side of the badge'
required: false
yellow:
description: 'At what percentage does the badge become yellow instead of red (default 30)'
required: false
link:
description: 'Optional URL when you click the badge'
required: false
runs:
using: 'composite'
steps:
- run: |
EXTRA_ARGS=""
if [[ -n '${{ inputs.color }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -color=${{ inputs.color }}"
fi
if [[ -n '${{ inputs.green }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -green=${{ inputs.green }}"
fi
if [[ -n '${{ inputs.target }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -target=${{ inputs.target }}"
fi
if [[ -n '${{ inputs.text }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -text=${{ inputs.text }}"
fi
if [[ -n '${{ inputs.value }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -value=${{ inputs.value }}"
fi
if [[ -n '${{ inputs.yellow }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -yellow=${{ inputs.yellow }}"
fi
if [[ -n '${{ inputs.link }}' ]]; then
EXTRA_ARGS="${EXTRA_ARGS} -link=${{ inputs.link }}"
fi
TEMP_DIR=$(mktemp -d)
curl -sf https://gobinaries.com/github.com/AlexBeauchemin/[email protected] | PREFIX=$TEMP_DIR sh
$TEMP_DIR/gobadge -filename=${{ inputs.filename }} $EXTRA_ARGS
rm -rf $TEMP_DIR
id: coverage-badge-go
shell: bash
branding:
icon: check-circle
color: white