-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathadd_device_handler.py
50 lines (46 loc) · 1.36 KB
/
add_device_handler.py
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
import json
import sys
import os
def main():
assert len(sys.argv) == 2
file_name = sys.argv[1]
github = "https://github.com/"
issue_content = os.environ["ISSUE_CONTENT"]
lines = issue_content.split("\n\n")
assert len(lines) == 6
url = lines[1]
print(url)
device = lines[3]
print(device)
code_of_conduct = lines[5]
print(code_of_conduct)
assert code_of_conduct.find("[X]") > 0
tmp = url.removesuffix("/").replace(github, "").split("/")
print(tmp)
assert len(tmp) == 2
maintainer = tmp[0]
print(maintainer)
maintainer_link = "%s%s" % (github, maintainer)
print(maintainer_link)
kernel_name = tmp[1]
print(kernel_name)
kernel_link = "%s%s/%s" % (github, maintainer, kernel_name)
print(kernel_link)
with open(file_name, "r") as f:
data = json.loads(f.read())
data.append(
{
"maintainer": maintainer,
"maintainer_link": maintainer_link,
"kernel_name": kernel_name,
"kernel_link": kernel_link,
"devices": device,
}
)
os.remove(file_name)
with open(file_name, "w") as f:
f.write(json.dumps(data, indent=4))
os.system("echo success=true >> $GITHUB_OUTPUT")
os.system("echo device=%s >> $GITHUB_OUTPUT" % device)
if __name__ == "__main__":
main()