diff --git a/.github/scripts/build-contributor-wall.py b/.github/scripts/build-contributor-wall.py new file mode 100644 index 0000000..f6767f4 --- /dev/null +++ b/.github/scripts/build-contributor-wall.py @@ -0,0 +1,62 @@ +import json +import re +from pathlib import Path + +README = Path("README.md") + +# Load contributors from the files +contributors = json.loads( + Path("/tmp/contributors.json").read_text(encoding="utf-8") +) + +cards = [] + +# It create one contributor card +for c in contributors: + cards.append( + f""" + + +{c['login']} +
+{c['login']} +
+
+   +""" +) + +# Build contributor wall +wall = f""" +
+ +### {len(contributors)} Contributors + +

+{"".join(cards)} +

+ +*Auto-updated daily ยท + +View all โ†’ +* + +
+""" + +# Read README +content = README.read_text(encoding="utf-8") + +# Replace everything between the markers +content = re.sub( + r".*?", + f"\n{wall}\n", + content, + flags=re.S, +) + +# Write updated README +README.write_text(content, encoding="utf-8") diff --git a/.github/workflows/contributor-wall.yml b/.github/workflows/contributor-wall.yml new file mode 100644 index 0000000..906b0b6 --- /dev/null +++ b/.github/workflows/contributor-wall.yml @@ -0,0 +1,44 @@ +name: Update Contributor Wall + +on: + push: + branches: + - main + + schedule: + - cron: "0 2 * * *" + + workflow_dispatch: + +concurrency: + group: contributor-wall + cancel-in-progress: false + +jobs: + update-wall: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Fetch contributors + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api "repos/${{ github.repository }}/contributors" \ + --paginate \ + | jq -s 'add | map(select(.type != "Bot"))' \ + > /tmp/contributors.json + + - name: Build wall + run: python ./.github/scripts/build-contributor-wall.py + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore: update contributor wall [skip ci]" + file_pattern: README.md diff --git a/README.md b/README.md index d4cf677..1786ade 100644 --- a/README.md +++ b/README.md @@ -81,13 +81,29 @@ If you're reading this and thinking ## Contributors -A huge thanks to the legends who decided to waste their CPU cycles on this: +## ๐Ÿ† Contributors - - - +Everyone who has helped prove that **1 is still 1**. -*Click on any contributor's avatar above to visit their GitHub profile. New contributors are automatically added here!* +This wall regenerates automatically whenever contributions are merged. + + +
+ +### Contributors + +

+ + itsdakshjain + +

+ +
+ ## The "Serious" Engineering Side