auto-reply-issue.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. name: Auto Reply to Issues
  2. on:
  3. issues:
  4. types: [labeled]
  5. permissions:
  6. issues: write
  7. contents: read
  8. # Limit concurrent runs to prevent rate limit issues
  9. concurrency:
  10. group: auto-reply-${{ github.event.issue.number }}
  11. cancel-in-progress: false
  12. jobs:
  13. auto-reply:
  14. # Only trigger when 'ai-reply' label is added; skip bot-created issues and issues already labeled 'copilot'
  15. if: |
  16. github.event.label.name == 'ai-reply' &&
  17. github.event.issue.user.login != 'github-actions[bot]' &&
  18. !contains(github.event.issue.labels.*.name, 'copilot')
  19. runs-on: ubuntu-latest
  20. # Increased timeout to 10 minutes to accommodate multiple API calls, file I/O, and network latency.
  21. timeout-minutes: 10
  22. steps:
  23. - uses: actions/checkout@v4
  24. - name: Build Repository Index
  25. id: repo_index
  26. run: |
  27. echo "Building repository index from AGENTS.md..."
  28. # Verify AGENTS.md exists
  29. if [ ! -f "AGENTS.md" ]; then
  30. echo "Error: AGENTS.md not found"
  31. exit 1
  32. fi
  33. # Extract sections 1-3 from AGENTS.md (up to but not including "## Development Guide")
  34. # This covers: Project Overview, Project Architecture, and Getting Started
  35. awk '/^## Development Guide/{exit} {print}' AGENTS.md > /tmp/repo_index.md
  36. # Verify extraction was successful (file should not be empty)
  37. if [ ! -s "/tmp/repo_index.md" ]; then
  38. echo "Error: Failed to extract content from AGENTS.md"
  39. exit 1
  40. fi
  41. echo "Repository index built successfully ($(wc -l < /tmp/repo_index.md) lines)"
  42. - name: Multi-turn AI Response
  43. id: ai_response
  44. uses: actions/github-script@v8
  45. with:
  46. github-token: ${{ secrets.GITHUB_TOKEN }}
  47. script: |
  48. const fs = require('fs');
  49. const path = require('path');
  50. const script = require('./.github/scripts/issue-ai-response.js');
  51. await script({ github, context, core, fs, path });
  52. env:
  53. OPENAI_URL: ${{ vars.OPENAI_URL }}
  54. OPENAI_KEY: ${{ secrets.OPENAI_KEY }}