This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (62 loc) · 2.33 KB
/
dco.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
55
56
57
58
59
60
61
62
63
name: Verify DCO
on:
schedule:
- cron: '*/15 * * * *'
jobs:
dco-helper:
runs-on: ubuntu-latest
steps:
- name: Verify DCO status for open pull requests
uses: actions/github-script@v5
with:
script: |
const owner = "chocoapp";
const repo = "tech-radar";
const pulls = await github.paginate(github.rest.pulls.list, {
state: "open",
owner,
repo,
});
for (const pull of pulls) {
// Pick out the PRs that have the DCO check
const checks = await github.rest.checks.listForRef({
owner,
repo,
ref: pull.head.sha,
check_name: "DCO",
status: "completed",
});
// Skip if there are no checks
if (!checks.data.check_runs.length) {
continue;
}
// Skip if the conclusion is not action_required
if (checks.data.check_runs[0].conclusion !== "action_required") {
console.log(`No checks found for PR #${pull.number}, skipping`);
continue;
}
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number: pull.number,
});
if (comments.find((c) =>
c.user.login === "github-actions[bot]" &&
c.body.includes("<!-- dco -->")
)
) {
console.log(`already commented on PR #${pull.number}, skipping`);
continue;
}
console.log(`creating comment on PR #${pull.number}`);
const body = `
Thanks for the contribution!
All commits need to be DCO signed before merging. Please refer to the the [DCO section in CONTRIBUTING.md](https://github.com/chocoapp/tech-radar/blob/main/CONTRIBUTING.md#developer-certificate-of-origin) or the [DCO](${checks.data.check_runs[0].html_url}) status for more info.
<!-- dco -->`;
await github.rest.issues.createComment({
repo,
owner,
issue_number: pull.number,
body,
});
}