Add Floyd-Warshall Algorithm in Python #621
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |