Triage Issues #657
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: Triage Issues | |
| on: | |
| schedule: | |
| - cron: '47 2 * * *' # Temporary: testing at 02:47 UTC | |
| workflow_dispatch: | |
| inputs: | |
| issue_number: | |
| description: 'Issue number to triage' | |
| required: false | |
| type: string | |
| start_issue: | |
| description: 'Start issue number for range (inclusive)' | |
| required: false | |
| type: string | |
| end_issue: | |
| description: 'End issue number for range (inclusive)' | |
| required: false | |
| type: string | |
| skip_commented: | |
| description: 'Skip issues that already have bot comments' | |
| required: false | |
| type: boolean | |
| default: true | |
| permissions: | |
| issues: write | |
| contents: read | |
| jobs: | |
| triage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout specific script version | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ror-community/curation_ops | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies from requirements.txt | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r triage_issues/requirements.txt | |
| - name: Get issues to process (scheduled runs) | |
| if: github.event_name == 'schedule' | |
| id: get-issues | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| run: | | |
| pip install aiohttp | |
| ISSUES=$(python get_issues_for_processing/get_issues_for_processing.py \ | |
| --repo "${{ github.repository }}" \ | |
| --required-label "triage needed" \ | |
| --exclude-label "auto-triaged") | |
| echo "issues=$ISSUES" >> $GITHUB_OUTPUT | |
| echo "Found issues: $ISSUES" | |
| - name: Validate inputs | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| if [[ -n "${{ github.event.inputs.issue_number }}" && ( -n "${{ github.event.inputs.start_issue }}" || -n "${{ github.event.inputs.end_issue }}" ) ]]; then | |
| echo "Error: Cannot specify both single issue and issue range" | |
| exit 1 | |
| fi | |
| if [[ -z "${{ github.event.inputs.issue_number }}" && ( -z "${{ github.event.inputs.start_issue }}" || -z "${{ github.event.inputs.end_issue }}" ) ]]; then | |
| echo "Error: Must specify either single issue number or both start and end issue numbers" | |
| exit 1 | |
| fi | |
| - name: Process issues | |
| env: | |
| GH_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| SKIP_COMMENTED: ${{ github.event.inputs.skip_commented || 'true' }} | |
| run: | | |
| # Determine which issues to process | |
| if [ "${{ github.event_name }}" = "schedule" ]; then | |
| ISSUES="${{ steps.get-issues.outputs.issues }}" | |
| if [ -z "$ISSUES" ]; then | |
| echo "No issues to process from scheduled query" | |
| exit 0 | |
| fi | |
| elif [ -n "${{ github.event.inputs.issue_number }}" ]; then | |
| ISSUES="${{ github.event.inputs.issue_number }}" | |
| else | |
| ISSUES=$(seq ${{ github.event.inputs.start_issue }} ${{ github.event.inputs.end_issue }}) | |
| fi | |
| echo "Processing issues: $ISSUES" | |
| for ISSUE in $ISSUES; do | |
| echo "" | |
| echo "========================================" | |
| echo "Processing issue #$ISSUE" | |
| echo "========================================" | |
| # Run triage script for single issue | |
| ISSUE_NUMBER=$ISSUE python triage_issues/triage_issues_action.py | |
| # Add label on success | |
| if [ $? -eq 0 ]; then | |
| gh issue edit $ISSUE --add-label "auto-triaged" --repo ${{ github.repository }} | |
| echo "Added auto-triaged label to issue #$ISSUE" | |
| else | |
| echo "::warning::Failed to process issue #$ISSUE" | |
| fi | |
| done | |
| echo "" | |
| echo "Processing complete" |