Build latest tag on main branch
clean old stuff from createreadmes
This commit is contained in:
parent
44bae3fa85
commit
556035bdd9
38
build.py
38
build.py
@ -30,6 +30,22 @@ def get_webhook():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def update_portainer_stack(webhook_id: str):
|
||||||
|
print("Updating portainer stack...")
|
||||||
|
resp = post(f"https://docker.cnml.de/api/stacks/webhooks/{webhook_id}")
|
||||||
|
if not resp.ok:
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
error = resp.json()
|
||||||
|
except Exception:
|
||||||
|
error = resp.content.decode()
|
||||||
|
raise Exception(error)
|
||||||
|
raise Exception(f"{error['message']} ({error['details']})")
|
||||||
|
except Exception as e:
|
||||||
|
print("Failed to update:", e)
|
||||||
|
else:
|
||||||
|
print("Stack successfully updated!")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
output_path = Path("dist")
|
output_path = Path("dist")
|
||||||
if output_path.exists():
|
if output_path.exists():
|
||||||
@ -42,22 +58,14 @@ if __name__ == '__main__':
|
|||||||
stdout=PIPE, check=True).stdout.decode().strip()
|
stdout=PIPE, check=True).stdout.decode().strip()
|
||||||
short_sha = run(["git", "rev-parse", "--short", "HEAD"],
|
short_sha = run(["git", "rev-parse", "--short", "HEAD"],
|
||||||
stdout=PIPE, check=True).stdout.decode().strip()
|
stdout=PIPE, check=True).stdout.decode().strip()
|
||||||
|
tags = [branch, short_sha]
|
||||||
|
if branch == 'main':
|
||||||
|
default_branch_tag = "latest"
|
||||||
|
print(f"On default branch, also building {default_branch_tag} tag!")
|
||||||
|
tags.append(default_branch_tag)
|
||||||
platforms = ['linux/amd64', 'linux/arm/v6', 'linux/arm/v7',
|
platforms = ['linux/amd64', 'linux/arm/v6', 'linux/arm/v7',
|
||||||
'linux/arm64/v8', 'linux/386', 'linux/ppc64le', 'linux/s390x']
|
'linux/arm64/v8', 'linux/386', 'linux/ppc64le', 'linux/s390x']
|
||||||
buildx("chenio/code2dfd", [branch, short_sha], platforms, dockerfile=dockerfile)
|
buildx("chenio/code2dfd", tags, platforms, dockerfile=dockerfile)
|
||||||
webhook_id = get_webhook()
|
webhook_id = get_webhook()
|
||||||
if webhook_id is not None:
|
if webhook_id is not None:
|
||||||
print("Updating portainer stack...")
|
update_portainer_stack(webhook_id)
|
||||||
resp = post(f"https://docker.cnml.de/api/stacks/webhooks/{webhook_id}")
|
|
||||||
if not resp.ok:
|
|
||||||
try:
|
|
||||||
try:
|
|
||||||
error = resp.json()
|
|
||||||
except Exception:
|
|
||||||
error = resp.content.decode()
|
|
||||||
raise Exception(error)
|
|
||||||
raise Exception(f"{error['message']} ({error['details']})")
|
|
||||||
except Exception as e:
|
|
||||||
print("Failed to update:", e)
|
|
||||||
else:
|
|
||||||
print("Stack successfully updated!")
|
|
||||||
|
@ -266,7 +266,7 @@ properties:
|
|||||||
items:
|
items:
|
||||||
type: integer""")
|
type: integer""")
|
||||||
|
|
||||||
def check_security_rules(security_rules: dict[Any, Any] | None) -> dict[int, SecurityRule]:
|
def check_security_rules(model_id: str, security_rules: dict[Any, Any] | None) -> dict[int, SecurityRule]:
|
||||||
if security_rules is None:
|
if security_rules is None:
|
||||||
raise Exception("Security rules file is empty!")
|
raise Exception("Security rules file is empty!")
|
||||||
for n in range(1, 19):
|
for n in range(1, 19):
|
||||||
@ -276,7 +276,7 @@ def check_security_rules(security_rules: dict[Any, Any] | None) -> dict[int, Sec
|
|||||||
jsonschema.validate(rule, rule_schema)
|
jsonschema.validate(rule, rule_schema)
|
||||||
rule: SecurityRule
|
rule: SecurityRule
|
||||||
if rule["status"] == "unknown":
|
if rule["status"] == "unknown":
|
||||||
warning(f"Rule {n} is still unknown!")
|
warning(f"In model {model_id}: Rule {n} is still unknown!")
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
warning("Not checking further rules!")
|
warning("Not checking further rules!")
|
||||||
raise Exception("Security rule {n}: {msg} at $.{n}.{path}".format(n=n, msg=e.message, path=e.json_path)) from e
|
raise Exception("Security rule {n}: {msg} at $.{n}.{path}".format(n=n, msg=e.message, path=e.json_path)) from e
|
||||||
@ -421,7 +421,7 @@ def write_model_readmes(dataset: Dataset):
|
|||||||
security_rules = None
|
security_rules = None
|
||||||
try:
|
try:
|
||||||
with security_rules_file.open('r') as f:
|
with security_rules_file.open('r') as f:
|
||||||
security_rules = check_security_rules(yaml.safe_load(f))
|
security_rules = check_security_rules(model_id, yaml.safe_load(f))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
warning("Security rules file not found at {}".format(security_rules_file))
|
warning("Security rules file not found at {}".format(security_rules_file))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -429,7 +429,7 @@ def write_model_readmes(dataset: Dataset):
|
|||||||
dir.mkdir(exist_ok=True)
|
dir.mkdir(exist_ok=True)
|
||||||
write_file_if_changed(readme, f"""---
|
write_file_if_changed(readme, f"""---
|
||||||
title: {slug}
|
title: {slug}
|
||||||
keywords: model TODO
|
keywords: model
|
||||||
tags: [{', '.join(get_tag_slug(tech) for tech in info['tech'])}]
|
tags: [{', '.join(get_tag_slug(tech) for tech in info['tech'])}]
|
||||||
sidebar: datasetdoc_sidebar
|
sidebar: datasetdoc_sidebar
|
||||||
permalink: {model_id}.html
|
permalink: {model_id}.html
|
||||||
@ -492,7 +492,6 @@ keywords: code2DFD introduction
|
|||||||
tags: [overview]
|
tags: [overview]
|
||||||
sidebar: datasetdoc_sidebar
|
sidebar: datasetdoc_sidebar
|
||||||
permalink: index.html
|
permalink: index.html
|
||||||
summary: Dataset of dataflow diagrams of microservice applications.
|
|
||||||
toc: false
|
toc: false
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user