Skip to content

Commit 0843d63

Browse files
fix(workflows): safe PR body parsing and idempotent summary comments (#74)
## Summary - Fix bot-sync-status PR body parsing that caused shell errors with newlines - Add idempotency check to prevent duplicate 'Generation Complete' comments ## Changes | File | Fix | |------|-----| | bot-sync-status.yml | Safely fetch PR body via gh pr view instead of direct variable interpolation | | gen-new-plot.yml | Check if summary comment exists before posting (prevents duplicates) | ## Root Cause - The PR_BODY variable syntax breaks when the body contains newlines - The approved label was added 3 times to issue #53, causing 3 duplicate comments ## Test plan - Merge to main - Create new simple plot request - Verify sync-status works without errors - Verify no duplicate comments
1 parent 3296b4c commit 0843d63

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ jobs:
5555
5656
elif [ "${{ github.event_name }}" == "pull_request" ]; then
5757
PR_NUM="${{ github.event.pull_request.number }}"
58-
PR_BODY="${{ github.event.pull_request.body }}"
58+
59+
# Safely get PR body using gh CLI to avoid shell escaping issues with newlines
60+
PR_BODY=$(gh pr view "$PR_NUM" --json body -q '.body' 2>/dev/null || echo "")
5961
6062
# Extract parent issue from PR body
6163
PARENT_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,29 @@ jobs:
318318
- name: Checkout repository
319319
uses: actions/checkout@v6
320320

321+
- name: Check if summary already posted
322+
id: check_summary
323+
env:
324+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
325+
run: |
326+
# Check if "Generation Complete" comment already exists (idempotency)
327+
EXISTING=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
328+
--jq '[.[] | select(.body | startswith("## Generation Complete"))] | length')
329+
330+
if [ "$EXISTING" -gt "0" ]; then
331+
echo "Summary already posted, skipping"
332+
echo "skip=true" >> $GITHUB_OUTPUT
333+
else
334+
echo "skip=false" >> $GITHUB_OUTPUT
335+
fi
336+
321337
- name: Post summary to main issue
338+
if: steps.check_summary.outputs.skip != 'true'
322339
env:
323340
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
324341
run: |
325342
SPEC_ID="${{ needs.check-conditions.outputs.spec_id }}"
326343
327-
# Collect results
328-
RESULTS=""
329-
for LIB in matplotlib seaborn plotly bokeh altair plotnine pygal highcharts; do
330-
JOB_NAME="generate-$LIB"
331-
# Note: We can't easily get job status in a summary job
332-
# The bot-sync-status workflow will update the main issue
333-
RESULTS="$RESULTS\n- **$LIB**: Check sub-issue for status"
334-
done
335-
336344
# Post summary comment
337345
gh issue comment ${{ github.event.issue.number }} --body "## Generation Complete
338346

0 commit comments

Comments
 (0)