From 606c44c57645e08c0346c1f1479a63e7cfb4284f Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:48:30 -0700 Subject: [PATCH] Add failure of job instead of action --- .github/workflows/pr-checklist.yml | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index a2b858042d..d0a719d1e8 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -20,10 +20,6 @@ on: pull_request: types: [opened, edited, synchronize] -permissions: - pull-requests: write - contents: write - jobs: checklist: runs-on: ubuntu-24.04 @@ -42,30 +38,14 @@ jobs: }); core.setOutput('body', pr_desc.data.body) core.setOutput('draft', pr_desc.data.draft) - - name: Check if PR is not draft - id: is-not-draft - run: | - if [ "${{ steps.pr.outputs.draft }}" = "true" ]; then - echo "PR is in draft state. Exiting." - exit 0 - fi - name: Check if all checkboxes are checked id: checkboxes run: | DESCRIPTION="${{ steps.pr.outputs.body }}" UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') - echo "Unchecked checkboxes: $UNCHECKED" echo "unchecked=$UNCHECKED" >> $GITHUB_OUTPUT - - name: Move PR to draft if not all checkboxes are checked - if: steps.checkboxes.outputs.unchecked != '0' - uses: actions/github-script@v7 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - script: | - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - draft: true - }); + - name: Fail if not all checkboxes are checked and PR is not draft + if: ${{ (steps.pr.outputs.draft == "false") && (steps.checkboxes.outputs.unchecked != '0') }} + run: | + echo "Unchecked checkboxes: ${{ steps.checkboxes.outputs.unchecked }}" + exit 1