Merge branch 'main' of https://github.com/ayanalamMOON/LeetCodeProble… #2
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: Auto-Update Documentation | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| paths: | |
| - 'Daily_Problems/**' | |
| - 'Regular_Practice_Problems/**' | |
| - 'Rgegular_Practice_Problems/**' # Handle the typo in folder name | |
| pull_request: | |
| branches: [ main, master ] | |
| paths: | |
| - 'Daily_Problems/**' | |
| - 'Regular_Practice_Problems/**' | |
| - 'Rgegular_Practice_Problems/**' | |
| jobs: | |
| update-documentation: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyyaml requests | |
| - name: Detect changes | |
| id: changes | |
| run: | | |
| # Get changed files | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) | |
| else | |
| CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD) | |
| fi | |
| echo "Changed files:" | |
| echo "$CHANGED_FILES" | |
| # Check if any problem files were added/modified | |
| DAILY_PROBLEMS_CHANGED=$(echo "$CHANGED_FILES" | grep -E "^(Daily_Problems|Rgegular_Practice_Problems|Regular_Practice_Problems)/" || true) | |
| if [ -n "$DAILY_PROBLEMS_CHANGED" ]; then | |
| echo "problems_changed=true" >> $GITHUB_OUTPUT | |
| echo "changed_files<<EOF" >> $GITHUB_OUTPUT | |
| echo "$DAILY_PROBLEMS_CHANGED" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "problems_changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run documentation updater | |
| if: steps.changes.outputs.problems_changed == 'true' | |
| run: | | |
| python .github/scripts/update_documentation.py | |
| env: | |
| CHANGED_FILES: ${{ steps.changes.outputs.changed_files }} | |
| - name: Commit and push changes | |
| if: steps.changes.outputs.problems_changed == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| # Add all modified documentation files | |
| git add README.md INDEX.md PERFORMANCE_ANALYSIS.md InterviewPreparation.md || true | |
| # Check if there are any changes to commit | |
| if git diff --staged --quiet; then | |
| echo "No documentation changes to commit" | |
| else | |
| git commit -m "🤖 Auto-update documentation for new problems | |
| - Updated README.md with new problem entries | |
| - Updated INDEX.md with problem categorization | |
| - Updated PERFORMANCE_ANALYSIS.md with performance metrics | |
| - Updated InterviewPreparation.md with interview references | |
| Changes detected in: ${{ steps.changes.outputs.changed_files }} | |
| Auto-generated by GitHub Actions 🚀" | |
| git push | |
| fi | |
| - name: Create summary | |
| if: steps.changes.outputs.problems_changed == 'true' | |
| run: | | |
| echo "## 📊 Documentation Update Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🔍 Detected Changes" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.changes.outputs.changed_files }}" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 📝 Updated Files" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ README.md" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ INDEX.md" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ PERFORMANCE_ANALYSIS.md" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ InterviewPreparation.md" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🚀 Status" >> $GITHUB_STEP_SUMMARY | |
| echo "Documentation automatically updated and committed! 🎉" >> $GITHUB_STEP_SUMMARY |