Skip to content

Commit ac74e3f

Browse files
authored
fix: contributors should: be mentioned with clean markdown links, be updated in doc-site replicas (#117)
Signed-off-by: Frederic BIDON <[email protected]>
1 parent 43c58d4 commit ac74e3f

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/contributors.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,48 @@ jobs:
7575
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7676
REPOSITORY: ${{ github.repository }}
7777
LINK_TO_PROFILE: "True"
78-
- name: Rename contributor file
78+
OUTPUT_FILENAME: "CONTRIBUTORS.md"
79+
- name: Relint contributor file
80+
# This wraps naked markdown links by the more correct "<...>" form.
7981
run: |
8082
rm -rf contributors.json
81-
mv contributors.md CONTRIBUTORS.md
83+
sed -i -E 's/([[:space:]]+)(https:\/\/[^ ]+)/\1<\2>/' CONTRIBUTORS.md
84+
- name: Propagate to other contributors documentation
85+
if: ${{ hashFiles('docs/**/CONTRIBUTORS.md') != '' }}
86+
run: |
87+
# extract the body of updated contributors from ./CONTRIBUTORS.md
88+
body=$(awk '
89+
BEGIN { found = 0; skip_blank = 0 }
90+
!found && /^# / { found = 1; skip_blank = 1; next }
91+
found && skip_blank && /^$/ { skip_blank = 0; next }
92+
found { skip_blank = 0; print }
93+
' "./CONTRIBUTORS.md")
94+
95+
mapfile -d '' -t files < <(find docs -type f -name CONTRIBUTORS.md -print0)
96+
for file in "${files[@]}"; do
97+
# extract the frontmatter and other leading notes from the document before appending updated contributions.
98+
header=$(awk '
99+
BEGIN { found_heading = 0; in_body = 0 }
100+
/^## / { found_heading = 1; print; next }
101+
found_heading && !in_body {
102+
# Blank line right after heading: print it and start looking at body
103+
if (/^$/) { print; in_body = 1; next }
104+
# Non-blank line right after heading: still part of heading block
105+
print; next
106+
}
107+
in_body {
108+
# First blank line after body paragraph: stop
109+
if (/^$/) exit
110+
print; next
111+
}
112+
{ print }
113+
' "${file}")
114+
{
115+
echo "${header}"
116+
echo ""
117+
echo "${body}"
118+
} > "${file}"
119+
done
82120
- name: Configure bot credentials
83121
uses: go-openapi/gh-actions/ci-jobs/bot-credentials@23cdaeff454807ac293a6e98cff552a2ea49be63 # v1.4.7
84122
id: bot-credentials

0 commit comments

Comments
 (0)