Skip to content

Commit 9c7ea1c

Browse files
committed
updated configs
1 parent 3b1d823 commit 9c7ea1c

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

.github/workflows/update-contributors.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@ on:
66
branches:
77
- main
88

9+
permissions:
10+
contents: write # <-- this is critical for push to work
11+
912
jobs:
1013
update:
1114
runs-on: ubuntu-latest
1215
steps:
1316
- name: Checkout repository
1417
uses: actions/checkout@v3
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }} # built-in token, no setup required
1520

1621
- name: Update Contributors in HALL_OF_FAME.md and README.md
1722
run: |
18-
# Fetch contributors, filter out bots, sort by contributions desc
1923
CONTRIBUTORS=$(curl -s "https://api.github.com/repos/admirerr/DSA-Collection/contributors?per_page=100" \
2024
| jq -r '.[] | select(.type != "Bot") | [.login, .avatar_url, .html_url, .contributions] | @tsv' \
2125
| sort -k4,4nr)
2226
23-
# Build table for Hall of Fame
2427
TABLE=$(echo "$CONTRIBUTORS" | awk -F'\t' '{printf "| ![%s](%s) [%s](%s) | %s |\n", $1, $2, $1, $3, $4}')
25-
26-
# Build avatars row for README
2728
AVATARS=$(echo "$CONTRIBUTORS" | awk -F'\t' '{printf "[<img src=\"%s\" width=\"50\" height=\"50\" alt=\"%s\"/>](%s) ", $2, $1, $3}')
2829
29-
# ---- Update HALL_OF_FAME.md ----
30+
# Update Hall of Fame
3031
awk -v table="$TABLE" '
3132
/Contributor \| Contributions/ {
3233
print;
@@ -38,7 +39,7 @@ jobs:
3839
{print}
3940
' HALL_OF_FAME.md > temp && mv temp HALL_OF_FAME.md
4041
41-
# ---- Update README.md ----
42+
# Update README
4243
awk -v avatars="$AVATARS" '
4344
/<!-- CONTRIBUTORS START -->/ {
4445
print;
@@ -52,10 +53,7 @@ jobs:
5253
5354
- name: Update Implementation Counts
5455
run: |
55-
# Total
5656
sed -i 's/| 🎯 \*\*Total Implementations\*\* | [0-9]\+ |/| 🎯 **Total Implementations** | 22 |/' HALL_OF_FAME.md
57-
58-
# Per language
5957
sed -i '/### Python/{n;s/- Implementations: [0-9]\+/- Implementations: 6/}' HALL_OF_FAME.md
6058
sed -i '/### C++/{n;s/- Implementations: [0-9]\+/- Implementations: 4/}' HALL_OF_FAME.md
6159
sed -i '/### Java/{n;s/- Implementations: [0-9]\+/- Implementations: 12/}' HALL_OF_FAME.md

0 commit comments

Comments
 (0)