Write correct manifests in forks

This commit is contained in:
Ayaz Salikhov
2025-02-21 20:33:00 +00:00
parent 73628de2cd
commit d9b6333f13
4 changed files with 29 additions and 6 deletions

View File

@@ -32,6 +32,7 @@ def write_build_history_line(
hist_lines_dir: Path,
filename: str,
all_tags: list[str],
repository: str,
) -> None:
LOGGER.info("Appending build history line")
@@ -42,8 +43,8 @@ def write_build_history_line(
commit_hash = GitHelper.commit_hash()
links_column = MARKDOWN_LINE_BREAK.join(
[
f"[Git diff](https://github.com/jupyter/docker-stacks/commit/{commit_hash})",
f"[Dockerfile](https://github.com/jupyter/docker-stacks/blob/{commit_hash}/images/{short_image_name}/Dockerfile)",
f"[Git diff](https://github.com/{repository}/commit/{commit_hash})",
f"[Dockerfile](https://github.com/{repository}/blob/{commit_hash}/images/{short_image_name}/Dockerfile)",
f"[Build manifest](./{filename})",
]
)
@@ -61,12 +62,19 @@ def write_manifest_file(
filename: str,
manifests: list[ManifestInterface],
container: Container,
repository: str,
) -> None:
manifest_names = [manifest.__class__.__name__ for manifest in manifests]
LOGGER.info(f"Using manifests: {manifest_names}")
markdown_pieces = [
ManifestHeader.create_header(short_image_name, registry, owner, BUILD_TIMESTAMP)
ManifestHeader.create_header(
registry=registry,
owner=owner,
short_image_name=short_image_name,
build_timestamp=BUILD_TIMESTAMP,
repository=repository,
)
] + [manifest.markdown_piece(container) for manifest in manifests]
markdown_content = "\n\n".join(markdown_pieces) + "\n"
@@ -82,6 +90,7 @@ def write_manifest(
variant: str,
hist_lines_dir: Path,
manifests_dir: Path,
repository: str,
) -> None:
LOGGER.info(f"Creating manifests for image: {short_image_name}")
taggers, manifests = get_taggers_and_manifests(short_image_name)
@@ -104,6 +113,7 @@ def write_manifest(
hist_lines_dir=hist_lines_dir,
filename=filename,
all_tags=all_tags,
repository=repository,
)
write_manifest_file(
registry=registry,
@@ -113,6 +123,7 @@ def write_manifest(
filename=filename,
manifests=manifests,
container=container,
repository=repository,
)
@@ -127,6 +138,11 @@ if __name__ == "__main__":
hist_lines_dir=True,
manifests_dir=True,
)
arg_parser.add_argument(
"--repository",
required=True,
help="Repository name on GitHub",
)
args = arg_parser.parse_args()
LOGGER.info(f"Current build timestamp: {BUILD_TIMESTAMP}")

View File

@@ -12,7 +12,11 @@ class ManifestHeader:
@staticmethod
def create_header(
short_image_name: str, registry: str, owner: str, build_timestamp: str
registry: str,
owner: str,
short_image_name: str,
build_timestamp: str,
repository: str,
) -> str:
commit_hash = GitHelper.commit_hash()
commit_hash_tag = GitHelper.commit_hash_tag()
@@ -36,7 +40,7 @@ class ManifestHeader:
- Build timestamp: {build_timestamp}
- Docker image: `{registry}/{owner}/{short_image_name}:{commit_hash_tag}`
- Docker image size: {image_size}
- Git commit SHA: [{commit_hash}](https://github.com/jupyter/docker-stacks/commit/{commit_hash})
- Git commit SHA: [{commit_hash}](https://github.com/{repository}/commit/{commit_hash})
- Git commit message:
```text