Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions .github/workflows/update-marketplace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
rsync -a --delete "$RUNNER_TEMP/marketplace-snapshot/cc/" marketplace/plugins/cc/

- name: Create marketplace pull request
id: create_pr
env:
GH_TOKEN: ${{ secrets.SENDBIRD_CODEX_MARKETPLACE_PUSH_TOKEN }}
REF_NAME: ${{ github.event.release.tag_name || inputs.ref || github.ref_name }}
Expand All @@ -80,6 +81,7 @@ jobs:

if git diff --quiet -- plugins/cc; then
echo "Marketplace snapshot already matches $REF_NAME"
echo "pr_number=" >> "$GITHUB_OUTPUT"
exit 0
fi

Expand All @@ -91,20 +93,45 @@ jobs:
git commit -m "Update cc plugin snapshot to $REF_NAME"
git push --force-with-lease origin "$BRANCH_NAME"

EXISTING_PR_NUMBER=$(gh pr list \
PR_NUMBER=$(gh pr list \
--repo "$MARKETPLACE_REPO" \
--head "$BRANCH_NAME" \
--json number \
--jq '.[0].number // empty')

if [ -n "$EXISTING_PR_NUMBER" ]; then
echo "Marketplace PR already exists: #$EXISTING_PR_NUMBER"
exit 0
if [ -z "$PR_NUMBER" ]; then
gh pr create \
--repo "$MARKETPLACE_REPO" \
--base main \
--head "$BRANCH_NAME" \
--title "Update cc plugin snapshot to $REF_NAME" \
--body "Update \`plugins/cc\` in the Sendbird Codex marketplace to \`$REF_NAME\` from \`sendbird/cc-plugin-codex\`."
PR_NUMBER=$(gh pr list \
--repo "$MARKETPLACE_REPO" \
--head "$BRANCH_NAME" \
--json number \
--jq '.[0].number // empty')
Comment on lines +109 to +113
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail when PR lookup returns empty after creation

After creating a PR, the workflow re-fetches it with gh pr list and then unconditionally exports pr_number even if that query returns empty. The merge step is gated on pr_number != '', so an empty lookup makes the job succeed without merging and reintroduces the “PR left open forever” behavior this change is trying to eliminate. gh pr create already reports the created PR URL; at minimum, assert PR_NUMBER is non-empty and exit 1 when it is not so the run fails loudly instead of silently skipping merge.

Useful? React with 👍 / 👎.

else
echo "Marketplace PR already exists: #$PR_NUMBER"
fi

gh pr create \
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"

- name: Merge marketplace pull request
if: steps.create_pr.outputs.pr_number != ''
env:
GH_TOKEN: ${{ secrets.SENDBIRD_CODEX_MARKETPLACE_PUSH_TOKEN }}
PR_NUMBER: ${{ steps.create_pr.outputs.pr_number }}
run: |
# Auto-snapshot PRs are deterministic from the source tag and need to
# land without a human in the loop, otherwise releases ship to npm but
# never reach the marketplace. We bypass branch protection here on
# purpose; if the token does not have admin rights on the marketplace
# repo, this step will fail loudly and the open PR remains for manual
# merge — which is strictly better than silently leaving v1.x.0 stuck
# in PR limbo.
gh pr merge "$PR_NUMBER" \
--repo "$MARKETPLACE_REPO" \
--base main \
--head "$BRANCH_NAME" \
--title "Update cc plugin snapshot to $REF_NAME" \
--body "Update \`plugins/cc\` in the Sendbird Codex marketplace to \`$REF_NAME\` from \`sendbird/cc-plugin-codex\`."
--squash \
--admin \
--delete-branch
Loading