From a29c3920e5a018f7da1349372adaee47603059ec Mon Sep 17 00:00:00 2001 From: "Brennan Wilkes (Text Groove)" Date: Thu, 22 Jan 2026 11:53:32 -0800 Subject: [PATCH] fix: PR JS --- .../workflows/stviz_create_pr_from_issue.yml | 1 - tools/stviz_apply_issue_edits.js | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stviz_create_pr_from_issue.yml b/.github/workflows/stviz_create_pr_from_issue.yml index d077fd4..cf79d53 100644 --- a/.github/workflows/stviz_create_pr_from_issue.yml +++ b/.github/workflows/stviz_create_pr_from_issue.yml @@ -45,7 +45,6 @@ jobs: node tools/stviz_apply_issue_edits.js - name: Close issue - if: always() env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_NUMBER: ${{ github.event.issue.number }} diff --git a/tools/stviz_apply_issue_edits.js b/tools/stviz_apply_issue_edits.js index 2f7c8e3..ed796c2 100644 --- a/tools/stviz_apply_issue_edits.js +++ b/tools/stviz_apply_issue_edits.js @@ -404,10 +404,20 @@ sh(`git push -u origin "${branch}"`); const prTitle = `STVIZ: SKU link updates (issue #${ISSUE_NUMBER})`; const prBody = `Automated PR created from issue #${ISSUE_NUMBER}: ${ISSUE_TITLE}`; -// Create PR and capture URL/number deterministically (no search/index lag) -const prUrl = sh( - `gh -R "${REPO}" pr create --base data --head "${branch}" --title "${prTitle}" --body "${prBody}" --json url --jq .url` -); +function extractPrUrl(out) { + // gh pr create usually prints the PR URL to stdout; be robust in case extra text appears. + const m = String(out || "").match(/https?:\/\/\S+\/pull\/\d+\S*/); + if (!m) die(`Could not find PR URL in gh output:\n${out}`); + return m[0]; +} + + // Create PR and capture URL/number without relying on unsupported flags + const prCreateOut = sh( + `gh -R "${REPO}" pr create --base data --head "${branch}" --title "${prTitle}" --body "${prBody}"` + ); + const prUrl = extractPrUrl(prCreateOut); + + const prNumber = sh(`gh -R "${REPO}" pr view "${prUrl}" --json number --jq .number`); sh(