Merge pull request #203 from Asmita-08/InfixToPostfixConverter #252
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: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update Contributors in HALL_OF_FAME.md and README.md | |
| run: | | |
| # Fetch contributors from GitHub | |
| NEW_CONTRIBUTORS=$(curl -s "https://api.github.com/repos/admirerr/DSA-Collection/contributors?per_page=100" \ | |
| | jq -r '.[] | select(.type != "Bot") | [.login, .avatar_url, .html_url, .contributions] | @tsv') | |
| # Extract existing contributors from HALL_OF_FAME.md | |
| EXISTING_CONTRIBUTORS=$(awk -F'\t' '/<div align=/{print $0}' HALL_OF_FAME.md || true) | |
| # Merge, remove duplicates, and sort by contributions descending | |
| ALL_CONTRIBUTORS=$(echo -e "$NEW_CONTRIBUTORS" | awk '!seen[$0]++' | sort -k4,4nr) | |
| # Build Hall of Fame table (full) | |
| TABLE=$(echo "$ALL_CONTRIBUTORS" | awk -F'\t' '{printf "| <div align=\"center\"><img src=\"%s\" width=\"50\" height=\"50\"/><br>[%s](%s)</div> | %s |\n", $2, $1, $3, $4}') | |
| # Build avatars row for README (full) | |
| AVATARS=$(echo "$ALL_CONTRIBUTORS" | awk -F'\t' '{printf "[<img src=\"%s\" width=\"50\" height=\"50\" alt=\"%s\"/>](%s) ", $2, $1, $3}') | |
| # ---- Update Hall of Fame ---- | |
| awk -v table="$TABLE" ' | |
| /Contributor \| Contributions/ { | |
| print; | |
| print "|-------------|---------------|"; | |
| print table; | |
| in_block=1; next; | |
| } | |
| in_block && /^\|/ {next} | |
| {print} | |
| ' HALL_OF_FAME.md > temp && mv temp HALL_OF_FAME.md | |
| # ---- Update README ---- | |
| awk -v avatars="$AVATARS" ' | |
| /<!-- CONTRIBUTORS START -->/ { | |
| print; | |
| print avatars; | |
| in_block=1; next; | |
| } | |
| in_block && /<!-- CONTRIBUTORS END -->/ {print; in_block=0; next} | |
| in_block {next} | |
| {print} | |
| ' README.md > temp && mv temp README.md | |
| - name: Update Implementation Counts | |
| run: | | |
| # Count implementations dynamically | |
| PY_COUNT=$(find . -type f -name "*.py" | wc -l) | |
| CPP_COUNT=$(find . -type f -name "*.cpp" | wc -l) | |
| JAVA_COUNT=$(find . -type f -name "*.java" | wc -l) | |
| # Total implementations | |
| TOTAL_COUNT=$((PY_COUNT + CPP_COUNT + JAVA_COUNT)) | |
| # Update counts in HALL_OF_FAME.md | |
| sed -i "s/| 🎯 \*\*Total Implementations\*\* | [0-9]\+ |/| 🎯 **Total Implementations** | $TOTAL_COUNT |/" HALL_OF_FAME.md | |
| sed -i "/### Python/{n;s/- Implementations: [0-9]\+/- Implementations: $PY_COUNT/}" HALL_OF_FAME.md | |
| sed -i "/### C++/{n;s/- Implementations: [0-9]\+/- Implementations: $CPP_COUNT/}" HALL_OF_FAME.md | |
| sed -i "/### Java/{n;s/- Implementations: [0-9]\+/- Implementations: $JAVA_COUNT/}" HALL_OF_FAME.md | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| git add README.md | |
| git add HALL_OF_FAME.md | |
| git commit -m "Update contributors and implementations" || echo "No changes to commit" | |
| git push |