Skip to content

Commit 5638ba8

Browse files
committed
fix: move CodeRabbit plan trigger to approved-issues workflow and simplify skill-label trigger
Signed-off-by: Anshul Kushwaha <137977998+sudo-anshul@users.noreply.github.com>
1 parent d66a1cd commit 5638ba8

3 files changed

Lines changed: 28 additions & 36 deletions

File tree

.github/scripts/coderabbit_plan_trigger.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ async function main({ github, context }) {
9797
// Validations
9898
if (!issue?.number) return console.log('No issue in payload');
9999

100+
if (issue.locked) {
101+
return console.log(`Issue #${issue.number} is locked. CodeRabbit plan trigger will be deferred until the issue is approved and unlocked.`);
102+
}
103+
100104
if (!hasBeginnerOrHigherLabel(issue, label)) {
101105
return console.log('Issue does not have beginner/intermediate/advanced label');
102106
}

.github/workflows/approved-issues.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ defaults:
1313

1414
permissions:
1515
issues: write
16+
contents: read
1617

1718
concurrency:
1819
group: approve-issues-${{ github.event.issue.number }}
@@ -50,3 +51,17 @@ jobs:
5051
issue-number: ${{ github.event.issue.number }}
5152
body: |
5253
Approved by @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
54+
55+
- name: Checkout repository
56+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
57+
with:
58+
persist-credentials: false
59+
60+
- name: Trigger CodeRabbit Plan
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
64+
with:
65+
script: |
66+
const script = require('./.github/scripts/coderabbit_plan_trigger.js');
67+
await script({ github, context });

.github/workflows/bot-coderabbit-plan-trigger.yml

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Triggers CodeRabbit's plan feature for difficulty-labeled issues.
2-
# It runs when a difficulty label is added to an unlocked issue, and again when
3-
# a previously locked issue is unlocked (e.g. after triage approval).
2+
# It runs when a difficulty label is added to an unlocked issue.
43
name: CodeRabbit Plan Trigger
54
on:
65
issues:
7-
types: [labeled, unlocked]
6+
types: [labeled]
87

98
permissions:
109
issues: write
@@ -16,50 +15,24 @@ jobs:
1615
concurrency:
1716
group: coderabbit-plan-${{ github.event.issue.number }}
1817
cancel-in-progress: false
18+
# Run only for open, unlocked issues when a difficulty label is added.
19+
if: >
20+
github.event.issue.state == 'open' &&
21+
github.event.issue.locked == false &&
22+
contains(fromJson('["skill: beginner","skill: intermediate","skill: advanced"]'), github.event.label.name)
1923
2024
steps:
2125
- name: Harden the runner
2226
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
2327
with:
2428
egress-policy: audit
2529

26-
- name: Evaluate trigger conditions
27-
id: should_run
28-
run: echo "value=true" >> "$GITHUB_OUTPUT"
29-
# Run only for open, unlocked issues that have beginner/intermediate/advanced difficulty.
30-
if: >
31-
github.event.issue.state == 'open' &&
32-
github.event.issue.locked == false &&
33-
(
34-
(
35-
github.event.action == 'labeled' &&
36-
contains(fromJson('["skill: beginner","skill: intermediate","skill: advanced"]'), github.event.label.name)
37-
) ||
38-
(
39-
github.event.action == 'unlocked' &&
40-
(
41-
contains(github.event.issue.labels.*.name, 'skill: beginner') ||
42-
contains(github.event.issue.labels.*.name, 'skill: intermediate') ||
43-
contains(github.event.issue.labels.*.name, 'skill: advanced')
44-
)
45-
)
46-
)
47-
48-
- name: Log skip context
49-
if: steps.should_run.outputs.value != 'true'
50-
run: |
51-
echo "::notice::Skipping CodeRabbit plan trigger"
52-
echo "::notice::action=${{ github.event.action }}"
53-
echo "::notice::issue_state=${{ github.event.issue.state }}"
54-
echo "::notice::issue_locked=${{ github.event.issue.locked }}"
55-
echo "::notice::issue_labels=${{ join(github.event.issue.labels.*.name, ', ') }}"
56-
5730
- name: Checkout repository
58-
if: steps.should_run.outputs.value == 'true'
5931
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
32+
with:
33+
persist-credentials: false
6034

6135
- name: Trigger CodeRabbit Plan
62-
if: steps.should_run.outputs.value == 'true'
6336
env:
6437
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6538
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 #v9.0.0

0 commit comments

Comments
 (0)