forked from WeblateOrg/meta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-dependabot
executable file
·52 lines (42 loc) · 1.3 KB
/
generate-dependabot
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
#!/usr/bin/env python3
"""Generates Dependabot configuration for Weblate repositories."""
import os
import sys
import ruamel.yaml
root = ruamel.yaml.comments.CommentedMap()
root.yaml_set_start_comment(
"This file is generated in https://github.com/WeblateOrg/meta/"
)
root["version"] = 2
root["updates"] = []
automerge = {"github-actions", "pip", "docker"}
detections = (
(".github/workflows", "github-actions", "/"),
("requirements.txt", "pip", "/"),
("requirements-lint.txt", "pip", "/"),
(".gitmodules", "gitsubmodule", "/"),
("Dockerfile", "docker", "/"),
("/scripts/yarn", "npm", "/scripts/yarn"),
)
if len(sys.argv) > 1:
os.chdir(sys.argv[1])
ecosystems = {
(ecosystem, directory)
for filename, ecosystem, directory in detections
if os.path.exists(filename)
}
for ecosystem, directory in sorted(ecosystems):
update = {
"package-ecosystem": ecosystem,
"directory": directory,
"schedule": {"interval": "daily"},
"labels": ["dependencies"],
}
# Add automerge label
if ecosystem in automerge:
update["labels"].append("automerge")
root["updates"].append(update)
yaml = ruamel.yaml.YAML()
with open(".github/dependabot.yml", "w") as handle:
yaml.indent(mapping=2, sequence=4, offset=2)
yaml.dump(root, handle)