Skip to content

Add Floyd-Warshall Algorithm in Python #621

Add Floyd-Warshall Algorithm in Python

Add Floyd-Warshall Algorithm in Python #621

name: πŸ† Update Contributors
on:
push:
branches: [main]
pull_request:
types: [closed]
branches: [main]
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
pull-requests: write
jobs:
update-contributors:
runs-on: ubuntu-latest
# Only run on push to main or when PR is merged (not just closed)
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true)
steps:
- name: πŸ“₯ Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: πŸ” Get contributor stats
id: contributors
run: |
echo "πŸ“Š Fetching contributor statistics..."
# Get contributors with commit counts, excluding GitHub Actions users
contributors=$(curl -s "https://api.github.com/repos/${{ github.repository }}/contributors?per_page=100" | \
jq -r '.[] | select(.login != "github-actions[bot]" and .login != "actions-user" and .type != "Bot") | "\(.login) \(.contributions)"')
echo "Contributors found (excluding bots):"
echo "$contributors"
# Count total contributors (excluding bots)
total_contributors=$(echo "$contributors" | grep -v '^$' | wc -l)
echo "total_contributors=$total_contributors" >> $GITHUB_OUTPUT
# Get top contributors
top_contributors=$(echo "$contributors" | head -10)
echo "top_contributors<<EOF" >> $GITHUB_OUTPUT
echo "$top_contributors" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: πŸ“Š Update repository stats
run: |
echo "πŸ“Š Updating repository statistics..."
# Update stats in README.md
if [ -f "README.md" ]; then
# Update contributor count in README
sed -i "s/🎯 \*\*[0-9]*+ Contributors\*\*/🎯 **${{ steps.contributors.outputs.total_contributors }}+ Contributors**/g" README.md
echo "βœ… Updated README.md with new contributor count"
fi
# Update stats in HALL_OF_FAME.md
if [ -f "HALL_OF_FAME.md" ]; then
# Update contributor count in Hall of Fame
sed -i "s/\*\*Total 2024 Contributors: [0-9]*+ Amazing Developers!\*\*/\*\*Total 2024 Contributors: ${{ steps.contributors.outputs.total_contributors }}+ Amazing Developers!\*\*/g" HALL_OF_FAME.md
sed -i "s/We extend our heartfelt gratitude to all \*\*[0-9]*+ contributors\*\*/We extend our heartfelt gratitude to all **${{ steps.contributors.outputs.total_contributors }}+ contributors**/g" HALL_OF_FAME.md
sed -i "s/| πŸ‘₯ \*\*Total Contributors\*\* | [0-9]*+ Amazing Developers |/| πŸ‘₯ **Total Contributors** | ${{ steps.contributors.outputs.total_contributors }}+ Amazing Developers |/g" HALL_OF_FAME.md
echo "βœ… Updated HALL_OF_FAME.md with new contributor count"
fi
- name: πŸ“ˆ Update language statistics
run: |
echo "πŸ“ˆ Updating language statistics..."
# Count files by language
c_files=$(find C/ -name "*.c" 2>/dev/null | wc -l || echo 0)
cpp_files=$(find CPP/ -name "*.cpp" 2>/dev/null | wc -l || echo 0)
java_files=$(find Java/ -name "*.java" 2>/dev/null | wc -l || echo 0)
python_files=$(find Python/ -name "*.py" 2>/dev/null | wc -l || echo 0)
js_files=$(find . -name "*.js" -not -path "./node_modules/*" 2>/dev/null | wc -l || echo 0)
go_files=$(find . -name "*.go" 2>/dev/null | wc -l || echo 0)
rust_files=$(find . -name "*.rs" 2>/dev/null | wc -l || echo 0)
total_implementations=$((c_files + cpp_files + java_files + python_files + js_files + go_files + rust_files))
echo "πŸ“Š Language Statistics:"
echo "C: $c_files files"
echo "C++: $cpp_files files"
echo "Java: $java_files files"
echo "Python: $python_files files"
echo "JavaScript: $js_files files"
echo "Go: $go_files files"
echo "Rust: $rust_files files"
echo "Total: $total_implementations implementations"
# Count supported languages
supported_languages=4 # Base languages: C, C++, Java, Python
[ $js_files -gt 0 ] && supported_languages=$((supported_languages + 1))
[ $go_files -gt 0 ] && supported_languages=$((supported_languages + 1))
[ $rust_files -gt 0 ] && supported_languages=$((supported_languages + 1))
echo "Supported languages: $supported_languages"
# Update README stats
if [ -f "README.md" ]; then
sed -i "s/πŸ’» \*\*[0-9]*+ Languages\*\*/πŸ’» **${supported_languages}+ Languages**/g" README.md
fi
- name: πŸ“… Update last modified date
run: |
echo "πŸ“… Updating last modified date..."
current_date=$(date +"%B %Y")
if [ -f "HALL_OF_FAME.md" ]; then
sed -i "s/\*Last updated: .* [0-9]*\*/\*Last updated: $current_date\*/g" HALL_OF_FAME.md
echo "βœ… Updated last modified date in HALL_OF_FAME.md"
fi
- name: πŸ” Check for changes
id: changes
run: |
if git diff --quiet; then
echo "No changes to commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Changed files:"
git diff --name-only
fi
- name: πŸ’Ύ Commit and push changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md HALL_OF_FAME.md
git commit -m "πŸ† Auto-update contributor statistics
- Updated contributor count: ${{ steps.contributors.outputs.total_contributors }}+ amazing developers
- Refreshed repository statistics
- Updated last modified date
πŸ€– Generated by GitHub Actions"
git push
- name: πŸ“‹ Generate summary
run: |
echo "πŸ† Contributors Update Summary"
echo "=============================="
echo ""
echo "πŸ“Š Statistics:"
echo " πŸ‘₯ Total Contributors: ${{ steps.contributors.outputs.total_contributors }}"
echo " πŸ”₯ Repository Status: Active"
echo " πŸ“… Last Updated: $(date)"
echo ""
echo "πŸŽ‰ Contributor statistics updated successfully!"
if [ "${{ steps.changes.outputs.has_changes }}" == "true" ]; then
echo "βœ… Changes committed and pushed"
else
echo "ℹ️ No changes needed"
fi