Skip to content

Commit d9b6333

Browse files
committed
Write correct manifests in forks
1 parent 73628de commit d9b6333

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

.github/workflows/docker-build-test-upload.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ jobs:
101101
--variant ${{ inputs.variant }}
102102
--hist-lines-dir /tmp/jupyter/hist_lines/
103103
--manifests-dir /tmp/jupyter/manifests/
104+
--repository ${{ github.repository }}
104105
shell: bash
105106
- name: Upload manifest file 💾
106107
uses: actions/upload-artifact@v4

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ linkcheck-docs: ## check broken links
7777

7878

7979
hook/%: VARIANT?=default
80+
hook/%: REPOSITORY?=$(OWNER)/docker-stacks
8081
hook/%: ## run post-build hooks for an image
8182
python3 -m tagging.apps.write_tags_file \
8283
--registry "$(REGISTRY)" \
@@ -90,7 +91,8 @@ hook/%: ## run post-build hooks for an image
9091
--short-image-name "$(notdir $@)" \
9192
--variant "$(VARIANT)" \
9293
--hist-lines-dir /tmp/jupyter/hist_lines/ \
93-
--manifests-dir /tmp/jupyter/manifests/
94+
--manifests-dir /tmp/jupyter/manifests/ \
95+
--repository "$(REPOSITORY)"
9496
python3 -m tagging.apps.apply_tags \
9597
--registry "$(REGISTRY)" \
9698
--owner "$(OWNER)" \

tagging/apps/write_manifest.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def write_build_history_line(
3232
hist_lines_dir: Path,
3333
filename: str,
3434
all_tags: list[str],
35+
repository: str,
3536
) -> None:
3637
LOGGER.info("Appending build history line")
3738

@@ -42,8 +43,8 @@ def write_build_history_line(
4243
commit_hash = GitHelper.commit_hash()
4344
links_column = MARKDOWN_LINE_BREAK.join(
4445
[
45-
f"[Git diff](https://github.com/jupyter/docker-stacks/commit/{commit_hash})",
46-
f"[Dockerfile](https://github.com/jupyter/docker-stacks/blob/{commit_hash}/images/{short_image_name}/Dockerfile)",
46+
f"[Git diff](https://github.com/{repository}/commit/{commit_hash})",
47+
f"[Dockerfile](https://github.com/{repository}/blob/{commit_hash}/images/{short_image_name}/Dockerfile)",
4748
f"[Build manifest](./{filename})",
4849
]
4950
)
@@ -61,12 +62,19 @@ def write_manifest_file(
6162
filename: str,
6263
manifests: list[ManifestInterface],
6364
container: Container,
65+
repository: str,
6466
) -> None:
6567
manifest_names = [manifest.__class__.__name__ for manifest in manifests]
6668
LOGGER.info(f"Using manifests: {manifest_names}")
6769

6870
markdown_pieces = [
69-
ManifestHeader.create_header(short_image_name, registry, owner, BUILD_TIMESTAMP)
71+
ManifestHeader.create_header(
72+
registry=registry,
73+
owner=owner,
74+
short_image_name=short_image_name,
75+
build_timestamp=BUILD_TIMESTAMP,
76+
repository=repository,
77+
)
7078
] + [manifest.markdown_piece(container) for manifest in manifests]
7179
markdown_content = "\n\n".join(markdown_pieces) + "\n"
7280

@@ -82,6 +90,7 @@ def write_manifest(
8290
variant: str,
8391
hist_lines_dir: Path,
8492
manifests_dir: Path,
93+
repository: str,
8594
) -> None:
8695
LOGGER.info(f"Creating manifests for image: {short_image_name}")
8796
taggers, manifests = get_taggers_and_manifests(short_image_name)
@@ -104,6 +113,7 @@ def write_manifest(
104113
hist_lines_dir=hist_lines_dir,
105114
filename=filename,
106115
all_tags=all_tags,
116+
repository=repository,
107117
)
108118
write_manifest_file(
109119
registry=registry,
@@ -113,6 +123,7 @@ def write_manifest(
113123
filename=filename,
114124
manifests=manifests,
115125
container=container,
126+
repository=repository,
116127
)
117128

118129

@@ -127,6 +138,11 @@ def write_manifest(
127138
hist_lines_dir=True,
128139
manifests_dir=True,
129140
)
141+
arg_parser.add_argument(
142+
"--repository",
143+
required=True,
144+
help="Repository name on GitHub",
145+
)
130146
args = arg_parser.parse_args()
131147

132148
LOGGER.info(f"Current build timestamp: {BUILD_TIMESTAMP}")

tagging/manifests/header.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ class ManifestHeader:
1212

1313
@staticmethod
1414
def create_header(
15-
short_image_name: str, registry: str, owner: str, build_timestamp: str
15+
registry: str,
16+
owner: str,
17+
short_image_name: str,
18+
build_timestamp: str,
19+
repository: str,
1620
) -> str:
1721
commit_hash = GitHelper.commit_hash()
1822
commit_hash_tag = GitHelper.commit_hash_tag()
@@ -36,7 +40,7 @@ def create_header(
3640
- Build timestamp: {build_timestamp}
3741
- Docker image: `{registry}/{owner}/{short_image_name}:{commit_hash_tag}`
3842
- Docker image size: {image_size}
39-
- Git commit SHA: [{commit_hash}](https://github.com/jupyter/docker-stacks/commit/{commit_hash})
43+
- Git commit SHA: [{commit_hash}](https://github.com/{repository}/commit/{commit_hash})
4044
- Git commit message:
4145
4246
```text

0 commit comments

Comments
 (0)