-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
221 lines (183 loc) · 7.37 KB
/
__main__.py
File metadata and controls
221 lines (183 loc) · 7.37 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import pulumi
from git_automation.git_repository_component import GitRepositoryComponent
_BUILD_TARGET = {"go": "main.go", "rust": "bin"}
_BUILD_PLATFORMS = {
"docker": [
{"os": "linux", "arch": "amd64", "runner": "ubuntu-24.04"},
{"os": "linux", "arch": "arm64", "runner": "ubuntu-24.04-arm"},
],
"go": [
{"os": "linux", "arch": "amd64", "runner": "ubuntu-24.04"},
{"os": "linux", "arch": "arm64", "runner": "ubuntu-24.04-arm"},
{"os": "darwin", "arch": "amd64", "runner": "macos-15-intel"},
{"os": "darwin", "arch": "arm64", "runner": "macos-15"},
{"os": "windows", "arch": "amd64", "runner": "windows-2025"},
{"os": "windows", "arch": "arm64", "runner": "windows-11-arm"},
],
"rust": [
{"target": "x86_64-unknown-linux-gnu", "runner": "ubuntu-24.04"},
{"target": "x86_64-unknown-linux-musl", "runner": "ubuntu-24.04"},
{"target": "aarch64-unknown-linux-gnu", "runner": "ubuntu-24.04-arm"},
{"target": "aarch64-unknown-linux-musl", "runner": "ubuntu-24.04-arm"},
{"target": "x86_64-apple-darwin", "runner": "macos-15-intel"},
{"target": "aarch64-apple-darwin", "runner": "macos-15"},
{"target": "x86_64-pc-windows-msvc", "runner": "windows-2025"},
{"target": "x86_64-pc-windows-gnu", "runner": "windows-2025"},
{"target": "aarch64-pc-windows-msvc", "runner": "windows-11-arm"},
],
}
config = pulumi.Config()
author = config.get_object("author")
owner = pulumi.Config("github").require("owner")
if author is None:
raise ValueError("Author can't be None")
for repository_config in config.get_object("repositories", []):
workflow = False
workflow_lint = False
workflow_test = False
workflow_package = False
workflow_changelog = False
workflow_documentation = False
if "workflow" in repository_config:
workflow = True
workflow_lint = (
"lint" in repository_config["workflow"]
and repository_config["workflow"]["lint"]
)
workflow_test = (
"test" in repository_config["workflow"]
and repository_config["workflow"]["test"]
)
workflow_package = (
"package" in repository_config["workflow"]
and repository_config["workflow"]["package"]
)
workflow_changelog = (
"changelog" in repository_config["workflow"]
and repository_config["workflow"]["changelog"]
)
workflow_documentation = (
"documentation" in repository_config["workflow"]
and repository_config["workflow"]["documentation"]
)
renovatebot = "renovatebot" in repository_config
package_name = repository_config.get("package", None)
devcontainer = repository_config.get("devcontainer", False)
helm_chart_name = repository_config.get("helm_chart_name", None)
helm = helm_chart_name is not None
docker = repository_config.get("docker", False)
language = repository_config.get("language", None)
versions = repository_config.get("versions", [])
gitignore = repository_config.get("gitignore", False)
readme = repository_config.get("readme", False)
binary = language in ["rust", "go"] and package_name
build_target = repository_config.get(
"build_target", _BUILD_TARGET.get(language, None)
)
binary_platforms = _BUILD_PLATFORMS.get(language, None)
docker_platforms = _BUILD_PLATFORMS["docker"] if docker else None
repository = GitRepositoryComponent(
owner=owner,
name=repository_config["name"],
default_branch_name=config.get("default_branch_name", "main"),
branch_name=config.get("branch_name"),
description=repository_config["description"],
author_fullname=author["fullname"],
author_email=author["email"],
homepage_url=repository_config.get("homepage_url", None),
topics=repository_config.get("topics", None),
pages=repository_config.get("pages", None),
)
repository.sync_repository_ruleset(
language,
versions,
binary,
binary_platforms,
workflow_lint,
workflow_test,
docker,
docker_platforms,
)
repository.sync_workflow_repository_permission()
repository.sync_action_repository_permission()
repository.sync_dependabot()
app_installation_ids = config.get_object("app_installation_ids")
if app_installation_ids:
repository.sync_app_installation(renovatebot, app_installation_ids)
if "license" in repository_config and repository_config["license"]:
repository.sync_licence(repository_config["license"])
funding = config.get_object("funding")
if funding:
repository.sync_funding(funding)
repository.sync_pull_request_template()
repository.sync_contributing()
repository.sync_support()
repository.sync_issue_template(language)
repository.sync_codeowner()
repository.sync_vscode_config(language)
repository.sync_linter_config(language)
repository.sync_editorconfig(language, docker)
repository.sync_gitattributes()
if gitignore:
repository.sync_gitignore(language, helm)
contact_email = config.get("contact_email")
if contact_email:
repository.sync_code_of_conduct(contact_email)
security_email = config.get("security_email")
if security_email:
repository.sync_security(security_email)
if "label" in repository_config and repository_config["label"]:
repository.sync_label(language, docker, renovatebot)
if renovatebot:
renovatebot_configs = repository_config["renovatebot"].get("configs", [])
if devcontainer and "devcontainer" not in renovatebot_configs:
renovatebot_configs.append("devcontainer")
if helm and "helm" not in renovatebot_configs:
renovatebot_configs.append("helm")
if docker and "docker" not in renovatebot_configs:
renovatebot_configs.append("docker")
renovatebot_configs.append(language)
repository.sync_renovatebot(
repository_config["renovatebot"].get("schedule", None),
language,
renovatebot_configs,
repository_config["renovatebot"].get("additionnal_configs", []),
)
if "logo" in repository_config:
repository.sync_logo(repository_config["logo"])
if readme:
readme_args = {} if isinstance(readme, bool) else readme
dev = []
if devcontainer:
dev.append("devcontainer")
repository.sync_readme(
repository_config["title"],
repository_config["description"],
repository_config.get("documentation_url", None),
"logo" in repository_config,
language,
package_name,
workflow_lint,
workflow_test,
readme_args.get("docker", docker),
helm,
helm_chart_name,
dev,
readme_args.get("configuration", True),
)
if workflow:
repository.sync_workflow(
package_name,
language,
versions,
binary,
build_target,
binary_platforms,
workflow_lint,
workflow_test,
workflow_package,
workflow_documentation,
workflow_changelog,
docker,
docker_platforms,
)