[Intermediate]: #20
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
| # This workflow automatically triggers CodeRabbit's plan feature for intermediate and advanced issues. | |
| # Fix for #1427: Only triggers when a beginner/intermediate/advanced label is specifically added, | |
| # preventing duplicate runs when other labels are added to the same issue. | |
| name: CodeRabbit Plan Trigger | |
| on: | |
| issues: | |
| types: [labeled] | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Run without posting comments" | |
| required: false | |
| default: "true" | |
| type: choice | |
| options: | |
| - "true" | |
| - "false" | |
| permissions: | |
| issues: write | |
| contents: read | |
| jobs: | |
| coderabbit_plan_trigger: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: coderabbit-plan-${{ github.event.issue.number }} | |
| cancel-in-progress: false | |
| # Only run when the newly added label is beginner, intermediate, or advanced (case-insensitive) | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.action == 'labeled' && | |
| contains(fromJson('["beginner","intermediate","advanced","Beginner","Intermediate","Advanced"]'), github.event.label.name)) | |
| steps: | |
| - name: Harden the runner | |
| uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 | |
| - name: Trigger CodeRabbit Plan | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || 'false' }} | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | |
| with: | |
| script: | | |
| const script = require('./.github/scripts/coderabbit_plan_trigger.js'); | |
| await script({ github, context}); |