-
Notifications
You must be signed in to change notification settings - Fork 256
63 lines (56 loc) · 2.27 KB
/
Copy pathapprove_dco.yaml
File metadata and controls
63 lines (56 loc) · 2.27 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
53
54
55
56
57
58
59
60
61
62
63
# M-flow CI — Enforce Developer Certificate of Origin (DCO) on external PRs.
# Organization members are exempt; external contributors must include the
# DCO affirmation statement in the PR body.
name: community | DCO Compliance Gate
on:
pull_request:
types: [opened, edited, reopened, synchronize, ready_for_review]
permissions:
contents: read
pull-requests: read
jobs:
dco-gate:
name: Verify DCO statement
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Check DCO affirmation in PR body
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const ORG = 'FlowElement-ai';
const author = context.payload.pull_request.user.login;
const body = context.payload.pull_request.body ?? '';
const DCO_TEXT =
'I affirm that all code in every commit of this pull request ' +
'conforms to the terms of the M-flow Developer Certificate of Origin';
// ── Step 1: Check organisation membership ──────────────────────
let memberOfOrg = false;
try {
await github.rest.orgs.getMembershipForUser({
org: ORG,
username: author,
});
memberOfOrg = true;
core.info(`✔ ${author} belongs to ${ORG} — DCO check skipped.`);
} catch (err) {
if (err.status === 404) {
core.info(`${author} is not a member of ${ORG} — DCO required.`);
} else {
core.setFailed(`Organisation lookup failed: ${err.message}`);
return;
}
}
// ── Step 2: Enforce DCO for non-members ────────────────────────
if (!memberOfOrg && !body.includes(DCO_TEXT)) {
core.setFailed(
[
'DCO check failed.',
'',
'Please add the following statement to your PR description:',
'',
` ${DCO_TEXT}`,
].join('\n'),
);
}