-
Notifications
You must be signed in to change notification settings - Fork 49
54 lines (51 loc) · 1.93 KB
/
pr-dod-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Definition of done Check
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
jobs:
check-unchecked-tasks:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const getPendingTasks = (body) => {
let responseString = "";
try {
const uncompletedTasks = body.match(/(- \[[ ]\].+)/g);
if (uncompletedTasks != undefined) {
responseString += 'Uncompleted Tasks\n';
uncompletedTasks.forEach(u => {
responseString += `${u}\n`;
});
}
} catch (e) {
responseString = "";
}
return responseString;
}
(async () => {
try {
const prBody = context?.payload?.pull_request?.body;
if (!prBody) {
core.info("PR don't have tasks to check");
return
}
core.debug('Getting a list of uncompleted tasks: ');
let pendingTasks = getPendingTasks(prBody);
core.debug(pendingTasks);
let isTaskListCompleted = false;
if (!pendingTasks) {
isTaskListCompleted = true;
}
core.debug(`All tasks completed: ${isTaskListCompleted}`);
if (isTaskListCompleted) {
core.info(`SUCCESS: All tasks completed`);
return;
} else {
core.setFailed(`FAILED: Some tasks are still pending! \n${pendingTasks}\nLength: ${pendingTasks.length}`);
}
} catch (error) {
core.setFailed(error.message)
}
})();