From e0acd9b11195730f3ec1ee97baeb501638016319 Mon Sep 17 00:00:00 2001 From: David O Neill Date: Mon, 12 Feb 2024 16:15:47 +0000 Subject: [PATCH] Change failing PR to draft --- .github/workflows/label_pr.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/label_pr.yml b/.github/workflows/label_pr.yml index 15571a866c..57faeb71b8 100644 --- a/.github/workflows/label_pr.yml +++ b/.github/workflows/label_pr.yml @@ -24,6 +24,38 @@ jobs: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/pr_labeler.yml + convert-to-draft: + runs-on: ubuntu-latest + name: Change failing PRS to draft + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 14 + + - name: Install dependencies + run: npm install -g github + + - name: Check CI status + id: check-ci + run: | + status=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/check-suites | \ + jq -r '.check_suites[0].conclusion') + echo "CI Status: $status" + echo "::set-output name=ci_status::$status" + + - name: Convert to Draft on CI Failure + if: steps.check-ci.outputs.ci_status == 'failure' + run: gh pr edit ${{ github.event.number }} --draft + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + community: runs-on: ubuntu-latest timeout-minutes: 20