Improvements for workflow! #1
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: π CI + CD Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' # Daily at midnight for README updates | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| # Code Quality Checks | |
| code-quality: | |
| runs-on: ubuntu-latest | |
| name: π Code Quality | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| - name: Run Codespell | |
| run: pipx run codespell | |
| continue-on-error: true | |
| - name: Run Ruff Check | |
| run: pipx run ruff check --output-format=github | |
| continue-on-error: true | |
| - name: Run Ruff Format | |
| run: pipx run ruff format | |
| continue-on-error: true | |
| - name: Install Black | |
| run: pip install black | |
| - name: Run Black Formatter | |
| run: black . | |
| continue-on-error: true | |
| # Update README Statistics | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| name: π§ Update README Stats | |
| if: github.event_name == 'push' || github.event_name == 'schedule' | |
| needs: code-quality | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| - name: Count Python files and lines | |
| run: | | |
| PY_FILES=$(find . -name "*.py" | wc -l) | |
| TOTAL_LINES=$(find . -name "*.py" -exec cat {} + | wc -l) | |
| echo "PY_FILES=$PY_FILES" >> $GITHUB_ENV | |
| echo "TOTAL_LINES=$TOTAL_LINES" >> $GITHUB_ENV | |
| - name: Update README.md | |
| run: | | |
| STATS="π Total lines of code: $TOTAL_LINES\nπ Number of Python files: $PY_FILES" | |
| DATE="π Last updated: $(date -u +"%Y-%m-%d %H:%M UTC")" | |
| sed -i "/<!-- STATS:START -->/,/<!-- STATS:END -->/c\\<!-- STATS:START -->\n$STATS\n<!-- STATS:END -->" README.md | |
| sed -i "/<!-- UPDATED:START -->/,/<!-- UPDATED:END -->/c\\<!-- UPDATED:START -->\n$DATE\n<!-- UPDATED:END -->" README.md | |
| - name: Commit changes | |
| run: | | |
| git config --global user.name "GitHub Actions Bot" | |
| git config --global user.email "[email protected]" | |
| git add README.md | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "π§ Update README stats" | |
| git push | |
| fi | |
| # Auto-reply to new issues | |
| auto-reply: | |
| runs-on: ubuntu-latest | |
| name: π€ Auto-Reply | |
| if: github.event_name == 'issues' && github.event.action == 'opened' | |
| steps: | |
| - name: Comment on new issue | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const issueNumber = context.issue.number; | |
| const username = context.payload.issue.user.login; | |
| const comment = [ | |
| `π Hello @${username}, thank you for opening an issue!`, | |
| ``, | |
| `I will get back to you as soon as I can. - 1501henify`, | |
| ``, | |
| `We appreciate your input β Have a great day/night!` | |
| ].join('\n'); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| body: comment | |
| }); |