Skip to content

Commit 3296b4c

Browse files
Review and fix GitHub Actions workflows (#72)
- Fix regex patterns to match actual format: **Parent Issue:** and **Sub-Issue:** - Add sub_issue_number and library fields to plot_metadata.json in gen-preview.yml - Update bot-sync-status.yml to search for correct "Parent Issue" format - Update bot-auto-merge.yml, gen-update-plot.yml, bot-ai-review.yml patterns
1 parent 353214a commit 3296b4c

5 files changed

Lines changed: 34 additions & 21 deletions

File tree

.github/workflows/bot-ai-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ jobs:
9494
LIBRARY="${{ steps.metadata.outputs.library }}"
9595
fi
9696
97-
# Extract sub-issue from PR body if not in metadata
97+
# Extract sub-issue from PR body if not in metadata (format: **Sub-Issue:** #NUM)
9898
SUB_ISSUE="${{ steps.metadata.outputs.sub_issue_number }}"
9999
if [ -z "$SUB_ISSUE" ]; then
100-
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
100+
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
101101
fi
102102
103103
echo "spec_id=$SPEC_ID" >> $GITHUB_OUTPUT

.github/workflows/bot-auto-merge.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868
run: |
6969
PR_BODY="${{ github.event.pull_request.body }}"
70-
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
70+
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
7171
echo "number=$SUB_ISSUE" >> $GITHUB_OUTPUT
7272
7373
- name: React with rocket emoji
@@ -154,8 +154,8 @@ jobs:
154154
LIBRARY=$(echo "$BRANCH" | cut -d'/' -f3)
155155
156156
# Extract issues from PR body
157-
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
158-
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP 'Parent Issue: #\K\d+' | head -1 || echo "")
157+
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
158+
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")
159159
160160
# Fallback: search for main issue
161161
if [ -z "$MAIN_ISSUE" ]; then
@@ -231,7 +231,7 @@ jobs:
231231
fi
232232
233233
# Get all sub-issues for this main issue
234-
SUB_ISSUES=$(gh issue list --search "Parent: #$MAIN_ISSUE in:body" --json number,labels -q '.')
234+
SUB_ISSUES=$(gh issue list --search "**Parent Issue:** #$MAIN_ISSUE in:body" --json number,labels -q '.')
235235
236236
# Count statuses
237237
TOTAL=$(echo "$SUB_ISSUES" | jq 'length')

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
if echo "$LABELS" | grep -q "sub-issue"; then
3838
# Find parent from issue body
3939
BODY=$(gh issue view $ISSUE_NUM --json body -q '.body')
40-
PARENT_NUM=$(echo "$BODY" | grep -oP 'Parent: #\K\d+' | head -1 || echo "")
40+
PARENT_NUM=$(echo "$BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")
4141
4242
if [ -n "$PARENT_NUM" ]; then
4343
echo "parent_number=$PARENT_NUM" >> $GITHUB_OUTPUT
@@ -58,7 +58,7 @@ jobs:
5858
PR_BODY="${{ github.event.pull_request.body }}"
5959
6060
# Extract parent issue from PR body
61-
PARENT_NUM=$(echo "$PR_BODY" | grep -oP 'Parent Issue: #\K\d+' | head -1 || echo "")
61+
PARENT_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")
6262
6363
if [ -n "$PARENT_NUM" ]; then
6464
echo "parent_number=$PARENT_NUM" >> $GITHUB_OUTPUT
@@ -84,7 +84,7 @@ jobs:
8484
PARENT_NUM="${{ steps.parent.outputs.parent_number }}"
8585
8686
# Get all sub-issues for this parent
87-
# Using GitHub's sub-issues API or searching for issues with "Parent: #N" in body
87+
# Using GitHub's sub-issues API or searching for issues with "Parent Issue: #N" in body
8888
SUB_ISSUES=$(gh api graphql -f query='
8989
query($owner: String!, $repo: String!, $parent: Int!) {
9090
repository(owner: $owner, name: $repo) {
@@ -103,9 +103,9 @@ jobs:
103103
}
104104
}' -f owner="${{ github.repository_owner }}" -f repo="${{ github.event.repository.name }}" -F parent="$PARENT_NUM" 2>/dev/null || echo '{"data":{"repository":{"issue":{"subIssues":{"nodes":[]}}}}}')
105105
106-
# Fallback: search for issues with "Parent: #N" in body
106+
# Fallback: search for issues with "Parent Issue: #N" in body
107107
if [ "$(echo "$SUB_ISSUES" | jq '.data.repository.issue.subIssues.nodes | length')" == "0" ]; then
108-
SUB_ISSUES_SEARCH=$(gh issue list --search "Parent: #$PARENT_NUM in:body" --json number,title,labels,state)
108+
SUB_ISSUES_SEARCH=$(gh issue list --search "**Parent Issue:** #$PARENT_NUM in:body" --json number,title,labels,state)
109109
echo "$SUB_ISSUES_SEARCH" > /tmp/sub_issues.json
110110
else
111111
echo "$SUB_ISSUES" | jq '.data.repository.issue.subIssues.nodes' > /tmp/sub_issues.json

.github/workflows/gen-preview.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,35 @@ jobs:
125125
CHANGED_ARRAY=$(echo "$CHANGED_FILES" | jq -R -s -c 'split("\n") | map(select(length > 0))')
126126
echo "changed_files=$CHANGED_ARRAY" >> $GITHUB_OUTPUT
127127
128-
- name: Extract issue number from PR
128+
- name: Extract issue number and metadata from PR
129129
id: get_issue
130130
if: steps.check.outputs.should_run == 'true' && steps.changed_plots.outputs.has_plots == 'true' && steps.get_pr.outputs.pr_number != ''
131131
env:
132132
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133133
run: |
134-
PR_BODY=$(gh pr view ${{ steps.get_pr.outputs.pr_number }} --json body -q '.body')
135-
ISSUE_NUM=$(echo "$PR_BODY" | grep -oP '#\K\d+' | head -1 || echo "")
134+
PR_DATA=$(gh pr view ${{ steps.get_pr.outputs.pr_number }} --json body,headRefName)
135+
PR_BODY=$(echo "$PR_DATA" | jq -r '.body')
136+
BRANCH=$(echo "$PR_DATA" | jq -r '.headRefName')
137+
138+
# Extract parent issue from PR body (format: **Parent Issue:** #NUM)
139+
ISSUE_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")
140+
141+
# Extract sub-issue from PR body (format: **Sub-Issue:** #NUM)
142+
SUB_ISSUE_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
143+
144+
# Extract library from branch name (format: auto/{spec-id}/{library})
145+
LIBRARY=$(echo "$BRANCH" | cut -d'/' -f3)
136146
137147
if [ -z "$ISSUE_NUM" ]; then
138148
# Try to find issue by branch name
139-
BRANCH=$(gh pr view ${{ steps.get_pr.outputs.pr_number }} --json headRefName -q '.headRefName')
140-
SPEC_ID=$(echo "$BRANCH" | sed 's/auto\///')
149+
SPEC_ID=$(echo "$BRANCH" | cut -d'/' -f2)
141150
ISSUE_NUM=$(gh issue list --label plot-request --search "$SPEC_ID in:title" --json number -q '.[0].number' || echo "")
142151
fi
143152
144153
echo "issue_num=$ISSUE_NUM" >> $GITHUB_OUTPUT
145-
echo "Found issue: #$ISSUE_NUM"
154+
echo "sub_issue_num=$SUB_ISSUE_NUM" >> $GITHUB_OUTPUT
155+
echo "library=$LIBRARY" >> $GITHUB_OUTPUT
156+
echo "Found issue: #$ISSUE_NUM, sub-issue: #$SUB_ISSUE_NUM, library: $LIBRARY"
146157
147158
- name: Setup Google Cloud authentication
148159
if: steps.check.outputs.should_run == 'true' && steps.changed_plots.outputs.has_plots == 'true'
@@ -327,6 +338,8 @@ jobs:
327338
{
328339
"pr_number": ${{ steps.get_pr.outputs.pr_number }},
329340
"issue_number": "${{ steps.get_issue.outputs.issue_num }}",
341+
"sub_issue_number": "${{ steps.get_issue.outputs.sub_issue_num }}",
342+
"library": "${{ steps.get_issue.outputs.library }}",
330343
"bucket": "${GCS_BUCKET}",
331344
"base_path": "plots",
332345
"timestamp": "${TIMESTAMP}",

.github/workflows/gen-update-plot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ jobs:
5757
SPEC_ID=$(echo "$BRANCH" | cut -d'/' -f2)
5858
LIBRARY=$(echo "$BRANCH" | cut -d'/' -f3)
5959
60-
# Extract sub-issue from PR body
61-
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
60+
# Extract sub-issue from PR body (format: **Sub-Issue:** #NUM)
61+
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
6262
63-
# Extract main issue from PR body
64-
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP 'Parent Issue: #\K\d+' | head -1 || echo "")
63+
# Extract main issue from PR body (format: **Parent Issue:** #NUM)
64+
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")
6565
6666
echo "spec_id=$SPEC_ID" >> $GITHUB_OUTPUT
6767
echo "library=$LIBRARY" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)