Skip to content

Commit 01cc267

Browse files
committed
Add PR checklist worklfow
1 parent 1953eab commit 01cc267

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/pr-checklist.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#===============================================================================
2+
# Copyright 2024 Intel Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#===============================================================================
16+
17+
name: Check PR Checklist
18+
19+
on:
20+
pull_request:
21+
types: [opened, edited, synchronize, ready_for_review, converted_to_draft]
22+
23+
permissions:
24+
contents: read
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
checklist:
32+
name: Close all checkboxes before moving from draft
33+
timeout-minutes: 5
34+
runs-on: ubuntu-24.04
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
- name: Get pull request details
39+
id: pr
40+
uses: actions/github-script@v7
41+
with:
42+
script: |
43+
const pr_desc = await github.rest.pulls.get({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
pull_number: context.payload.pull_request.number
47+
});
48+
core.setOutput('body', pr_desc.data.body)
49+
core.setOutput('draft', pr_desc.data.draft)
50+
core.setOutput('author_type', pr_desc.data.user.type)
51+
- name: Check if all checkboxes are checked
52+
id: checkboxes
53+
env:
54+
DESCRIPTION: ${{ steps.pr.outputs.body }}
55+
run: |
56+
UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]' || true)
57+
echo "unchecked=$UNCHECKED" >> $GITHUB_OUTPUT
58+
- name: Fail if not all checkboxes are checked, PR is not draft and author is not a bot
59+
if: ${{ (steps.pr.outputs.draft == 'false') && (steps.checkboxes.outputs.unchecked != '0') && (steps.pr.outputs.author_type != 'Bot') }}
60+
run: |
61+
echo "Unchecked checkboxes: ${{ steps.checkboxes.outputs.unchecked }}"
62+
exit 1

0 commit comments

Comments
 (0)