name: Contributor Recognition
on:
workflow_dispatch:
permissions:
contents: write
jobs:
update-contributors:
name: Update Contributors List
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Generate contributors
run: |
{
echo "# Contributors"
echo ""
echo "Thank you to all our contributors!"
echo ""
} > CONTRIBUTORS.md
git log --format='%aN <%aE>' | sort -u \
| grep -v 'github-actions\|dependabot' | while read -r line; do
echo "- $line" >> CONTRIBUTORS.md
done
total_contributors=$(git log --format='%aN' | sort -u \
| grep -cv 'github-actions\|dependabot')
{
echo ""
echo "## Statistics"
echo ""
echo "- Total contributors: ${total_contributors}"
echo "- Total commits: $(git rev-list --count HEAD)"
echo "- First commit: $(git log --reverse --format='%ai' | head -1)"
echo "- Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
} >> CONTRIBUTORS.md
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet CONTRIBUTORS.md; then
git add CONTRIBUTORS.md
git commit -m "chore: update contributors list [skip ci]"
git push
fi