Skip to content

Commit fc59b47

Browse files
fix: add job-level conditions to skip irrelevant workflow runs
- plot-prepare: only when plot-request label added - bot-link-issue: only for plot-update labeled issues - bot-sync-status: only for impl sub-issues or in-progress main issues
1 parent cac9438 commit fc59b47

3 files changed

Lines changed: 20 additions & 46 deletions

File tree

.github/workflows/bot-link-issue.yml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,14 @@ on:
66

77
jobs:
88
link-sub-issue:
9+
# Only run for issues with plot-update label
10+
if: contains(github.event.issue.labels.*.name, 'plot-update')
911
runs-on: ubuntu-latest
1012
permissions:
1113
issues: write
1214

1315
steps:
14-
- name: Check conditions
15-
id: check
16-
run: |
17-
LABELS="${{ join(github.event.issue.labels.*.name, ',') }}"
18-
19-
if [[ ! "$LABELS" =~ plot-update ]]; then
20-
echo "::notice::Skipping: Issue does not have 'plot-update' label"
21-
echo "should_run=false" >> $GITHUB_OUTPUT
22-
exit 0
23-
fi
24-
25-
echo "should_run=true" >> $GITHUB_OUTPUT
26-
2716
- name: Extract parent issue number
28-
if: steps.check.outputs.should_run == 'true'
2917
id: extract
3018
env:
3119
ISSUE_BODY: ${{ github.event.issue.body }}
@@ -44,7 +32,7 @@ jobs:
4432
echo "Found parent issue: #$PARENT_NUM"
4533
4634
- name: Get issue node IDs
47-
if: steps.check.outputs.should_run == 'true' && steps.extract.outputs.has_parent == 'true'
35+
if: steps.extract.outputs.has_parent == 'true'
4836
id: get_ids
4937
env:
5038
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -85,7 +73,7 @@ jobs:
8573
fi
8674
8775
- name: Create sub-issue relationship
88-
if: steps.check.outputs.should_run == 'true' && steps.extract.outputs.has_parent == 'true' && steps.get_ids.outputs.valid == 'true'
76+
if: steps.extract.outputs.has_parent == 'true' && steps.get_ids.outputs.valid == 'true'
8977
env:
9078
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9179
continue-on-error: true
@@ -108,7 +96,7 @@ jobs:
10896
' -f parentId="$PARENT_ID" -f subIssueId="$CHILD_ID" || echo "Sub-issue API not available or failed"
10997
11098
- name: Post comment on parent issue
111-
if: steps.check.outputs.should_run == 'true' && steps.extract.outputs.has_parent == 'true'
99+
if: steps.extract.outputs.has_parent == 'true'
112100
env:
113101
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114102
run: |
@@ -127,7 +115,7 @@ jobs:
127115
🤖 *Automated link by pyplots CI*"
128116
129117
- name: Post confirmation on child issue
130-
if: steps.check.outputs.should_run == 'true' && steps.extract.outputs.has_parent == 'true'
118+
if: steps.extract.outputs.has_parent == 'true'
131119
env:
132120
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133121
run: |

.github/workflows/bot-sync-status.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ on:
1212

1313
jobs:
1414
sync-status:
15+
# Only run for relevant events:
16+
# - issues: must have plot-request:impl OR (plot-request AND in-progress)
17+
# - pull_request/workflow_run: always check (step logic handles filtering)
18+
if: |
19+
github.event_name != 'issues' ||
20+
contains(github.event.issue.labels.*.name, 'plot-request:impl') ||
21+
(contains(github.event.issue.labels.*.name, 'plot-request') && contains(github.event.issue.labels.*.name, 'in-progress'))
1522
runs-on: ubuntu-latest
1623
permissions:
1724
contents: read

.github/workflows/plot-prepare.yml

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ concurrency:
1919

2020
jobs:
2121
prepare:
22+
# Only run when plot-request label is added (not other labels)
23+
if: github.event.label.name == 'plot-request'
2224
runs-on: ubuntu-latest
2325
permissions:
2426
contents: write
@@ -38,43 +40,20 @@ jobs:
3840
id: check
3941
env:
4042
ISSUE_TITLE: ${{ github.event.issue.title }}
41-
LABEL_NAME: ${{ github.event.label.name }}
4243
run: |
43-
echo "=== Debug Info ==="
44-
echo "Event: ${{ github.event_name }}"
45-
echo "Label added: $LABEL_NAME"
46-
echo "Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}"
47-
echo "Issue title: $ISSUE_TITLE"
48-
echo "=================="
49-
50-
# Only trigger when plot-request label is added
51-
if [[ "$LABEL_NAME" != "plot-request" ]]; then
52-
echo "::notice::Skipping: Not the 'plot-request' label"
53-
echo "should_run=false" >> $GITHUB_OUTPUT
54-
exit 0
55-
fi
56-
5744
# Check if this is an update request
5845
HAS_UPDATE="${{ contains(github.event.issue.labels.*.name, 'update') }}"
5946
if [[ "$HAS_UPDATE" == "true" ]]; then
6047
echo "is_update=true" >> $GITHUB_OUTPUT
61-
echo "::notice::This is an UPDATE request"
6248
else
6349
echo "is_update=false" >> $GITHUB_OUTPUT
64-
echo "::notice::This is a NEW request"
6550
fi
6651
67-
# Skip if already has spec-id in title (already processed)
68-
if [[ "$ISSUE_TITLE" =~ ^\[[a-z0-9-]+\] ]]; then
69-
EXISTING_ID=$(echo "$ISSUE_TITLE" | grep -oP '^\[\K[a-z0-9-]+(?=\])' || echo "")
70-
# For updates, having spec-id is expected - continue
71-
if [[ "$HAS_UPDATE" == "true" ]]; then
72-
echo "::notice::Update request with existing spec ID: $EXISTING_ID"
73-
else
74-
echo "::notice::Skipping: Issue already has spec ID: $EXISTING_ID"
75-
echo "should_run=false" >> $GITHUB_OUTPUT
76-
exit 0
77-
fi
52+
# For NEW requests: skip if already has spec-id in title
53+
if [[ "$ISSUE_TITLE" =~ ^\[[a-z0-9-]+\] ]] && [[ "$HAS_UPDATE" != "true" ]]; then
54+
echo "::notice::Skipping: Issue already has spec ID in title"
55+
echo "should_run=false" >> $GITHUB_OUTPUT
56+
exit 0
7857
fi
7958
8059
echo "should_run=true" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)