Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 12 additions & 69 deletions .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,26 @@
name: πŸ§‘β€πŸ’» Smart Contributor Updater
name: πŸ§‘β€πŸ’» Update Contributors Automatically

on:
schedule:
- cron: "0 * * * *" # Setiap 1 jam
workflow_dispatch:

permissions:
contents: write
pull-requests: write
pull_request:
types: [closed]
branches:
- main

jobs:
update-contributors:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
name: 🧾 Auto Update Contributors in README.md

steps:
- name: 🧩 Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚑ Restore Previous Contributor Hash
id: cache
uses: actions/cache@v4
- name: Generate contributors section
uses: akhilmhdh/contributors-readme-action@v2.3.10
with:
path: .cache_contributors_hash
key: contributor-hash-${{ github.repository }}
restore-keys: |
contributor-hash-

- name: πŸ“₯ Get Current Contributor Hash
id: contributors
run: |
curl -s "https://api.github.com/repos/${{ github.repository }}/contributors?per_page=100" \
| jq -r '.[].login' | sort | md5sum | cut -d " " -f1 > new_hash.txt
echo "hash=$(cat new_hash.txt)" >> $GITHUB_OUTPUT

- name: πŸ’Ύ Get Previous Hash (from cache)
id: previous
run: |
if [ -f .cache_contributors_hash ]; then
echo "hash=$(cat .cache_contributors_hash)" >> $GITHUB_OUTPUT
else
echo "hash=none" >> $GITHUB_OUTPUT
fi

- name: πŸ” Compare Contributor Hashes
id: compare
run: |
if [ "${{ steps.contributors.outputs.hash }}" = "${{ steps.previous.outputs.hash }}" ]; then
echo "same=true" >> $GITHUB_OUTPUT
echo "βœ… No new contributors found."
else
echo "same=false" >> $GITHUB_OUTPUT
echo "πŸ†• New contributors detected!"
fi

- name: ✏️ Update Contributors in README.md
if: steps.compare.outputs.same == 'false'
uses: akhilmhdh/contributors-readme-action@v2.3.11
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
readme_path: "README.md"
image_size: 100
columns_per_row: 6
use_username: true
commit_message: "πŸ§‘β€πŸ’» chore: update contributors list"

- name: πŸ’Ύ Save New Hash to Cache
if: steps.compare.outputs.same == 'false'
run: |
echo "${{ steps.contributors.outputs.hash }}" > .cache_contributors_hash

- name: πŸš€ Create Pull Request (if branch protected)
if: steps.compare.outputs.same == 'false'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "auto/update-contributors"
title: "πŸ€– Auto update contributors list"
body: "Automatically updated the contributor section in README.md πŸ’«"
commit_message: "πŸ€– Update contributors list"
readme_path: README.md
github_token: ${{ secrets.GITHUB_TOKEN }}
Loading