-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (99 loc) · 4.71 KB
/
cla.yml
File metadata and controls
102 lines (99 loc) · 4.71 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: "Verify CLA"
on:
workflow_call:
jobs:
verify-cla:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Parse Extracted Authors
env:
GH_TOKEN: ${{ github.token }}
uses: actions/github-script@v7
id: parse_authors
with:
script: |
try {
const commits = await github.request('GET /repos/${{github.repository }}/pulls/${{ github.event.number }}/commits', {
headers: {
'Accept': 'application/json'
}
})
//uncomment for debugging, but not in production
//console.log("Received commits " + JSON.stringify(commits["data"]))
var involved_authors = []
var missingAuthors = []
for(const commit of commits.data) {
if (!commit.author || !commit.author.login) {
missingAuthors.push(commit.sha)
}
}
if(missingAuthors.length != 0) {
console.log("❌ Cannot get all authors of commits:")
for (const item of missingAuthors) {
console.log(" * " + item);
}
core.setFailed("❌ Cannot get all authors of some commits. Please make sure that your commit email matches a verified email associated with your github account! See full log for details")
}
for(const commit of commits.data) {
const author = commit.author.login
if (author === undefined) {
const authorFail = "Commit " +commit.sha+" does not have a committer with a github user. Cannot check CLA requirement!"
core.error(authorFail)
core.setFailed(authorFail)
}
console.log(commit.sha + " has author login name " + author)
if(! involved_authors.includes(author)) involved_authors.push(author)
}
console.log("PR ${{ github.event.number }} was authored by " + involved_authors)
} catch(err) {
core.error("Error while reading or parsing the JSON")
core.setFailed(err)
}
return involved_authors
- name: Match Authors
uses: actions/github-script@v7
id: check
with:
result-encoding: string
script: |
try {
const authors = JSON.parse(`${{ steps.parse_authors.outputs.result }}`)
const whitelist = await github.request("https://raw.githubusercontent.com/a-sit-plus/contributors/main/contributors.json")
if(whitelist.status != 200) {
core.error("Error while fetching contributor whitelist. status: "+ whitelist.status)
core.setFailed(whitelist.status)
}
var str="Thank you for your contribution! Unfortunately, we cannot yet review this PR because\n"
var fail=false
for (i in authors){
if(!whitelist.data.includes(authors[i])){
fail=true
str+=" * @"+authors[i]+" has yet to sign the CLA ❌\n"
}
}
if(fail) {
str+="\nTo proceed, please download and fill out the [A-SIT Plus Contributor Licence Agreement](https://a-sit-plus.github.io/ASP_CLA.pdf) (CLA). Either print, sign and scan it or (preferably) use an eIDAS-compliant qualified electronic signature. When done, send it to [email protected]. "
str+="\nInformation on the processing of your personal data can be found in the [A-SIT Plus privacy policy](https://a-sit-plus.github.io/ASP_Privacy.pdf)."
str+="\nBe sure to carefully read it and only sign the CLA if you accept the terms of this privacy policy! (Don't worry, it's a light read!)"
str+=" \nSee also CONTRIBUTING.md in this repository to revisit contribution guidelines, the CLA signing requirement, and our privacy policy."
} else {
str="🟢 All authors have signed the CLA"
}
} catch(err) {
core.error("Error while reading or parsing the JSON")
core.setFailed(err)
}
return str
- name: Add Summary
run: echo -e "### CLA Check\n ${{ steps.check.outputs.result }}" >> $GITHUB_STEP_SUMMARY
- name: isSuccess
uses: actions/github-script@v7
with:
script: |
const str = `${{ steps.check.outputs.result }}`
if(str != "🟢 All authors have signed the CLA") {
core.error(str)
core.setFailed(str)
}