|
6 | 6 | branches: |
7 | 7 | - main |
8 | 8 |
|
| 9 | +permissions: |
| 10 | + contents: write # <-- this is critical for push to work |
| 11 | + |
9 | 12 | jobs: |
10 | 13 | update: |
11 | 14 | runs-on: ubuntu-latest |
12 | 15 | steps: |
13 | 16 | - name: Checkout repository |
14 | 17 | uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + token: ${{ secrets.GITHUB_TOKEN }} # built-in token, no setup required |
15 | 20 |
|
16 | 21 | - name: Update Contributors in HALL_OF_FAME.md and README.md |
17 | 22 | run: | |
18 | | - # Fetch contributors, filter out bots, sort by contributions desc |
19 | 23 | CONTRIBUTORS=$(curl -s "https://api.github.com/repos/admirerr/DSA-Collection/contributors?per_page=100" \ |
20 | 24 | | jq -r '.[] | select(.type != "Bot") | [.login, .avatar_url, .html_url, .contributions] | @tsv' \ |
21 | 25 | | sort -k4,4nr) |
22 | 26 |
|
23 | | - # Build table for Hall of Fame |
24 | 27 | TABLE=$(echo "$CONTRIBUTORS" | awk -F'\t' '{printf "|  [%s](%s) | %s |\n", $1, $2, $1, $3, $4}') |
25 | | -
|
26 | | - # Build avatars row for README |
27 | 28 | AVATARS=$(echo "$CONTRIBUTORS" | awk -F'\t' '{printf "[<img src=\"%s\" width=\"50\" height=\"50\" alt=\"%s\"/>](%s) ", $2, $1, $3}') |
28 | 29 |
|
29 | | - # ---- Update HALL_OF_FAME.md ---- |
| 30 | + # Update Hall of Fame |
30 | 31 | awk -v table="$TABLE" ' |
31 | 32 | /Contributor \| Contributions/ { |
32 | 33 | print; |
|
38 | 39 | {print} |
39 | 40 | ' HALL_OF_FAME.md > temp && mv temp HALL_OF_FAME.md |
40 | 41 |
|
41 | | - # ---- Update README.md ---- |
| 42 | + # Update README |
42 | 43 | awk -v avatars="$AVATARS" ' |
43 | 44 | /<!-- CONTRIBUTORS START -->/ { |
44 | 45 | print; |
|
52 | 53 |
|
53 | 54 | - name: Update Implementation Counts |
54 | 55 | run: | |
55 | | - # Total |
56 | 56 | sed -i 's/| 🎯 \*\*Total Implementations\*\* | [0-9]\+ |/| 🎯 **Total Implementations** | 22 |/' HALL_OF_FAME.md |
57 | | -
|
58 | | - # Per language |
59 | 57 | sed -i '/### Python/{n;s/- Implementations: [0-9]\+/- Implementations: 6/}' HALL_OF_FAME.md |
60 | 58 | sed -i '/### C++/{n;s/- Implementations: [0-9]\+/- Implementations: 4/}' HALL_OF_FAME.md |
61 | 59 | sed -i '/### Java/{n;s/- Implementations: [0-9]\+/- Implementations: 12/}' HALL_OF_FAME.md |
|
0 commit comments