@@ -5,20 +5,31 @@ inputs:
5
5
token :
6
6
description : Token for commenting and labeling on contributor's PR
7
7
required : true
8
- infrastructure_token :
9
- description : Token for opening singee PR in conda/infrastructure
10
- required : true
11
8
label :
12
9
description : Label to apply to contributor's PR once CLA is singed
13
10
required : true
11
+ cla_repo :
12
+ description : Upstream repository in which to create PR
13
+ default : conda/infrastructure
14
+ cla_fork :
15
+ description : Fork of cla_repo in which to create branch
16
+ default : conda-bot/infrastructure
17
+ cla_token :
18
+ description : Token for opening singee PR in the provided `cla_repo`
19
+ required : true
20
+ cla_path :
21
+ description : Path to the CLA signees file within the provided `cla_repo`
22
+ default : .clabot
14
23
15
24
runs :
16
25
using : composite
17
26
steps :
27
+ # sha, labels, hasLabel
18
28
- name : Get PR metadata
19
29
id : pr
20
30
uses : actions/github-script@v6
21
31
with :
32
+ github-token : ${{ inputs.token }}
22
33
script : |
23
34
const { owner, repo, number } = context.issue;
24
35
const pullRequest = await github.rest.pulls.get({
27
38
pull_number: number,
28
39
});
29
40
console.log(pullRequest);
41
+
30
42
const sha = pullRequest.data.head.sha;
31
43
console.log(sha);
32
44
core.setOutput('sha', sha);
@@ -48,20 +60,21 @@ runs:
48
60
state : pending
49
61
sha : ${{ steps.pr.outputs.sha || github.sha }}
50
62
63
+ # contributors, hasSigned
51
64
- name : Check if current actor has signed
52
65
uses : actions/github-script@v6
53
66
id : contributors
54
67
with :
55
- github-token : ${{ inputs.token }}
56
68
script : |
57
69
console.log(context);
70
+ const [owner, repo] = '${{ inputs.cla_repo }}'.split("/", 1);
58
71
const getContributors = async () => {
59
72
try {
60
73
const results = (
61
74
await github.rest.repos.getContent({
62
- owner: 'conda' ,
63
- repo: 'infrastructure' ,
64
- path: '.clabot '
75
+ owner: owner ,
76
+ repo: repo ,
77
+ path: '${{ inputs.cla_path }} '
65
78
})
66
79
);
67
80
return JSON.parse(Buffer.from(results.data.content, results.data.encoding).toString('utf-8')).contributors;
@@ -72,12 +85,14 @@ runs:
72
85
}
73
86
const contributors = await getContributors();
74
87
console.log(contributors);
88
+ core.setOutput('contributors', contributors);
89
+
75
90
const pull_request = (context.payload.issue || context.payload.pull_request || context.payload);
76
91
const creator = pull_request.user.login;
77
92
console.log(creator);
93
+
78
94
const hasSigned = contributors.includes(creator);
79
95
console.log(hasSigned);
80
- core.setOutput('contributors', contributors);
81
96
core.setOutput('hasSigned', hasSigned);
82
97
83
98
# add cla-signed label if actor has already signed
@@ -106,31 +121,32 @@ runs:
106
121
name: '${{ inputs.label }}'
107
122
})
108
123
109
- # checkout conda/infrastructure to update .clabot
124
+ # checkout cla_repo to update cla_path
110
125
- uses : actions/checkout@v3
111
126
if : steps.contributors.outputs.hasSigned == 'false'
112
127
with :
113
- repository : conda/infrastructure
128
+ repository : ${{ inputs.cla_repo }}
114
129
115
- # update .clabot
130
+ # update cla_path
116
131
- shell : python
117
132
if : steps.contributors.outputs.hasSigned == 'false'
118
133
run : |
119
134
import json
120
135
from pathlib import Path
121
136
122
- path = Path(".clabot ")
123
- clabot = json.loads(path.read_text())
124
- clabot ["contributors"].append("${{ github.actor }}")
125
- clabot ["contributors"].sort()
126
- path.write_text(json.dumps(clabot ))
137
+ path = Path("${{ inputs.cla_path }} ")
138
+ signees = json.loads(path.read_text())
139
+ signees ["contributors"].append("${{ github.actor }}")
140
+ signees ["contributors"].sort()
141
+ path.write_text(json.dumps(signees ))
127
142
128
143
# create PR
129
144
- uses : peter-evans/create-pull-request@v4
130
145
id : cla-pr
131
146
if : steps.contributors.outputs.hasSigned == 'false'
132
147
with :
133
- token : ${{ inputs.infrastructure_token }}
148
+ push-to-fork : ${{ inputs.cla_fork }}
149
+ token : ${{ inputs.cla_token }}
134
150
branch : cla-${{ github.actor }}
135
151
commit-message : Adding CLA singee ${{ github.actor }}
136
152
title : Adding CLA singee ${{ github.actor }}
0 commit comments