Skip to content

Commit 697957c

Browse files
authored
feat(contributors): add output-format option for html or markdown (#59)
- html: enforces 64x64 size with width/height attributes (for VS Marketplace) - markdown: uses URL parameter only (for NuGet, default)
1 parent 4b6d002 commit 697957c

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

.github/workflows/contributors.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Update Contributors
22

33
on:
44
workflow_call:
5+
inputs:
6+
output-format:
7+
description: 'Output format: html (enforces image size) or markdown'
8+
required: false
9+
type: string
10+
default: 'markdown'
511

612
jobs:
713
contributors:
@@ -14,6 +20,7 @@ jobs:
1420
- name: Update contributors
1521
env:
1622
GH_TOKEN: ${{ secrets.CONTRIBUTORS_TOKEN }}
23+
OUTPUT_FORMAT: ${{ inputs.output-format }}
1724
run: |
1825
# Fetch code contributors (exclude bots)
1926
code_contributors=$(gh api repos/${{ github.repository }}/contributors --paginate --jq '.[] | select(.type != "Bot") | select(.login | test("\\[bot\\]$") | not) | .login')
@@ -42,8 +49,8 @@ jobs:
4249
other_contributors=$(echo -e "$code_contributors\n$issue_authors" | sort -u | grep -v '^$' | grep -v '^CalvinAllen$' || true)
4350
all_contributors=$(echo -e "CalvinAllen\n$other_contributors" | grep -v '^$')
4451
45-
# Build markdown for each contributor
46-
contributor_md=""
52+
# Build output for each contributor
53+
contributor_output=""
4754
for login in $all_contributors; do
4855
# Skip bots
4956
if [[ "$login" == *"[bot]" ]]; then
@@ -55,12 +62,18 @@ jobs:
5562
avatar=$(echo "$user_info" | jq -r '.avatar_url')
5663
url=$(echo "$user_info" | jq -r '.html_url')
5764
58-
contributor_md="$contributor_md[![$login](${avatar}&s=64)]($url) "
65+
if [[ "$OUTPUT_FORMAT" == "html" ]]; then
66+
# HTML format with enforced size
67+
contributor_output="$contributor_output<a href=\"$url\"><img src=\"${avatar}&s=64\" width=\"64\" height=\"64\" alt=\"$login\"></a> "
68+
else
69+
# Markdown format (default)
70+
contributor_output="$contributor_output[![$login](${avatar}&s=64)]($url) "
71+
fi
5972
done
6073
6174
# Build the contributors section
6275
contrib_section="<!-- readme: contributors -start -->
63-
$contributor_md
76+
$contributor_output
6477
<!-- readme: contributors -end -->"
6578
6679
# Update README between the markers

0 commit comments

Comments
 (0)