From 424175835470ffa3a7b70fd0f447771a7b951d7c Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Sun, 1 Jun 2025 11:47:13 -0700 Subject: [PATCH] use github cli --- .github/workflows/check-format.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 1433d7409..9ba814085 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -40,17 +40,20 @@ jobs: working-directory: server run: npm run format-check close-pr-if-needed: + if: always() runs-on: ubuntu-latest needs: [format-client, format-server] - if: | - always() && ( - needs.format-client.result == 'failure' || - needs.format-server.result == 'failure' - ) steps: - - name: Close PR - uses: peter-evans/close-pull@v3 - with: - comment: | - ❌ Formatting check failed — PR auto-closed. - Please run `npm run format` and push again. + - name: Get PR URL + id: pr + run: echo "PR_URL=$(jq -r .pull_request.url "$GITHUB_EVENT_PATH")" >> $GITHUB_ENV + + - name: Close PR using GitHub CLI + if: | + needs.format-client.result == 'failure' || + needs.format-server.result == 'failure' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr close "$PR_URL" --delete-branch --comment "❌ Formatting check failed — PR auto-closed. + Please run \`npm run format\` and push again."