Skip to content

Commit

Permalink
Add failure of job instead of action
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexsandruss committed Sep 26, 2024
1 parent cb91b96 commit 606c44c
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions .github/workflows/pr-checklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ on:
pull_request:
types: [opened, edited, synchronize]

permissions:
pull-requests: write
contents: write

jobs:
checklist:
runs-on: ubuntu-24.04
Expand All @@ -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

0 comments on commit 606c44c

Please sign in to comment.