-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.54 KB
/
dco.yml
File metadata and controls
52 lines (46 loc) · 1.54 KB
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
name: DCO Check
on:
pull_request:
branches:
- main
- master
permissions:
contents: read
pull-requests: read
jobs:
dco:
name: DCO Signed-Off
runs-on: ubuntu-latest
steps:
- name: Get PR commits
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const query = `query($owner:String!, $repo:String!, $pull_number:Int!) {
repository(owner:$owner, name:$repo) {
pullRequest(number:$pull_number) {
commits(first:100) {
nodes {
commit {
oid
message
}
}
}
}
}
}`;
const variables = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
};
const result = await github.graphql(query, variables);
const commits = result.repository.pullRequest.commits.nodes.map(node => node.commit);
const unsigned = commits.filter(commit => !commit.message.includes('Signed-off-by:'));
if (unsigned.length > 0) {
core.setFailed(`The following commits are not signed with DCO:\n${unsigned.map(c => c.oid).join('\n')}\n\nPlease sign your commits using 'git commit -s'.`);
} else {
console.log('All commits are signed with DCO!');
}