Skip to content

Commit 4342713

Browse files
authored
Merge pull request #51 from kaitj/maint/badge
Fix readme badge color and url
2 parents e56bc26 + 76fd38e commit 4342713

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.github/scripts/create_badge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ComplianceColor(str, Enum):
2121

2222
class ShieldColor(str, Enum):
2323
BRONZE = "#CD7F32"
24-
SILVER = "#1C274C"
24+
SILVER = "#C5C5C5"
2525
GOLD = "#FFD700"
2626

2727

@@ -93,7 +93,7 @@ def get_shield_color(tier: str) -> ShieldColor:
9393
def generate_shield(tier: str) -> ...:
9494
"""Generate base64 encoded svg shield"""
9595
shield_color = get_shield_color(tier)
96-
shield_xml = f"""<svg viewBox="0 0 24 24" fill="{shield_color}" xmlns="http://www.w3.org/2000/svg">
96+
shield_xml = f"""<svg viewBox="0 0 24 24" fill="{shield_color.value}" xmlns="http://www.w3.org/2000/svg">
9797
<path d="M3.37752 5.08241C3 5.62028 3 7.21907 3 10.4167V11.9914C3 17.6294 7.23896 20.3655 9.89856 21.5273C10.62 21.8424 10.9807 22 12 22C13.0193 22 13.38 21.8424 14.1014 21.5273C16.761 20.3655 21 17.6294 21 11.9914V10.4167C21 7.21907 21 5.62028 20.6225 5.08241C20.245 4.54454 18.7417 4.02996 15.7351 3.00079L15.1623 2.80472C13.595 2.26824 12.8114 2 12 2C11.1886 2 10.405 2.26824 8.83772 2.80472L8.26491 3.00079C5.25832 4.02996 3.75503 4.54454 3.37752 5.08241Z"/>
9898
</svg>
9999
"""
@@ -108,7 +108,7 @@ def generate_badge(true_count: int, false_count: int, highest_tier: str | None)
108108

109109
compliance_color = get_compliance_color(true_count / total)
110110
msg = f"{true_count}/{total}"
111-
badge_content = f"NMIND-{quote_plus(msg)}-{compliance_color}"
111+
badge_content = f"NMIND-{quote_plus(msg)}-{compliance_color.value}"
112112
if highest_tier:
113113
badge_content += (
114114
f"?logo=data:image/svg+xml;base64,{generate_shield(highest_tier)}"

.github/workflows/checklist.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
const hasApproved = labels.includes('approved');
2121
const hasChecklist = labels.includes('checklist');
2222
return hasApproved && hasChecklist;
23-
23+
2424
- name: Early exit
2525
if: steps.check_labels.outputs.result == 'false'
2626
run: echo "Not an approved checklist issue - exiting"
@@ -59,7 +59,7 @@ jobs:
5959
run: |
6060
git config user.name 'github-actions[bot]'
6161
git config user.email 'github-actions[bot]@users.noreply.github.com'
62-
62+
6363
- name: Commit files
6464
if: steps.check_labels.outputs.result == 'true'
6565
run: |
@@ -79,6 +79,17 @@ jobs:
7979
run: |
8080
badge_url=$(python .github/scripts/create_badge.py "${{ env.file_name }}")
8181
echo "badge=$(echo $badge_url)" >> $GITHUB_ENV
82+
83+
# Generate url-safe, directly from checklist (env.name already altered)
84+
- name: Generate URL-safe tool string
85+
if: steps.check_labels.outputs.result == 'true'
86+
run: |
87+
tool_url=$(echo "$checklist" \
88+
| jq -r '.name' \
89+
| tr '[:upper:]' '[:lower:]' \
90+
| sed 's/[^a-z0-9_ ]//g' \
91+
| tr ' ' '-')
92+
echo "safe_url=$(echo $tool_url)" >> $GITHUB_ENV
8293
8394
- name: Comment on issue
8495
if: steps.check_labels.outputs.result == 'true'
@@ -96,6 +107,6 @@ jobs:
96107
97108
📄 **To embed this badge in a `README.md`, use the following Markdown:**
98109
```md
99-
[![${{ env.name }}](${{ env.badge }})](https://nmind.org/proceedings/${{ env.name }})
110+
[![${{ env.name }}](${{ env.badge }})](https://nmind.org/proceedings/${{ env.safe_url }})
100111
```
101-
112+

0 commit comments

Comments
 (0)