From 0d4a32720e02b3eb3497860cc3965281867125c6 Mon Sep 17 00:00:00 2001 From: Stephanie Anderson Date: Wed, 25 Mar 2026 19:51:45 +0100 Subject: [PATCH] fix(ci): Use gh CLI to convert PR to draft The GraphQL convertPullRequestToDraft mutation doesn't work with GitHub App installation tokens. Switch to `gh pr ready --undo` which handles the auth correctly. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/enforce-draft-pr.yml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/enforce-draft-pr.yml b/.github/workflows/enforce-draft-pr.yml index 623fa84207..fcbd96be4c 100644 --- a/.github/workflows/enforce-draft-pr.yml +++ b/.github/workflows/enforce-draft-pr.yml @@ -18,6 +18,13 @@ jobs: private-key: ${{ secrets.SDK_MAINTAINER_BOT_PRIVATE_KEY }} - name: Convert PR to draft + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + gh pr ready "$PR_URL" --undo + + - name: Label and comment uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: github-token: ${{ steps.app-token.outputs.token }} @@ -25,24 +32,6 @@ jobs: const pullRequest = context.payload.pull_request; const repo = context.repo; - // Convert to draft via GraphQL (REST API doesn't support this) - try { - await github.graphql(` - mutation($pullRequestId: ID!) { - convertPullRequestToDraft(input: { pullRequestId: $pullRequestId }) { - pullRequest { - isDraft - } - } - } - `, { - pullRequestId: pullRequest.node_id - }); - } catch (error) { - core.warning(`Failed to convert PR to draft: ${error.message}`); - return; - } - // Label the PR so maintainers can filter/track violations await github.rest.issues.addLabels({ ...repo,