Skip to content

Commit e796b11

Browse files
authored
Properly generate wiki home page in forks (#2226)
* Properly generate wiki home page in forks * Better description
1 parent 332aac5 commit e796b11

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

.github/workflows/docker-wiki-update.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Download build manifests from GitHub artifacts and push them to GitHub wik
33
# This way we make sure we don't access wiki pages from several jobs simultaneously
44

55
env:
6-
PUSH_TO_REGISTRY: ${{ (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && (github.ref == 'refs/heads/main' || github.event_name == 'schedule') }}
6+
PUSH_TO_REGISTRY: ${{ github.ref == 'refs/heads/main' || github.event_name == 'schedule' }}
77

88
on:
99
workflow_call:
@@ -44,6 +44,7 @@ jobs:
4444
--wiki-dir wiki/
4545
--hist-lines-dir /tmp/jupyter/hist_lines/
4646
--manifests-dir /tmp/jupyter/manifests/
47+
--repository ${{ github.repository }}
4748
shell: bash
4849

4950
- name: Push Uncyclo to GitHub 📤

.github/workflows/docker.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ jobs:
463463
- image: pytorch-notebook
464464
variant: cuda12
465465
needs: [aarch64-images-tag-push, x86_64-images-tag-push]
466-
if: (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && !contains(github.event.pull_request.title, '[FAST_BUILD]')
466+
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
467467

468468
merge-tags-fast:
469469
uses: ./.github/workflows/docker-merge-tags.yml
@@ -478,19 +478,19 @@ jobs:
478478
image: [docker-stacks-foundation, base-notebook]
479479
variant: [default]
480480
needs: [aarch64-images-tag-push-fast, x86_64-images-tag-push-fast]
481-
if: (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && contains(github.event.pull_request.title, '[FAST_BUILD]')
481+
if: contains(github.event.pull_request.title, '[FAST_BUILD]')
482482

483483
wiki-update:
484484
uses: ./.github/workflows/docker-wiki-update.yml
485485
needs: [aarch64-images-tag-push, x86_64-images-tag-push]
486-
if: github.repository_owner == 'jupyter' && !contains(github.event.pull_request.title, '[FAST_BUILD]')
486+
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
487487
permissions:
488488
contents: write
489489

490490
wiki-update-fast:
491491
uses: ./.github/workflows/docker-wiki-update.yml
492492
needs: [aarch64-images-tag-push-fast, x86_64-images-tag-push-fast]
493-
if: github.repository_owner == 'jupyter' && contains(github.event.pull_request.title, '[FAST_BUILD]')
493+
if: contains(github.event.pull_request.title, '[FAST_BUILD]')
494494
permissions:
495495
contents: write
496496

tagging/Home.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Jupyter Docker Stacks build manifests
2+
3+
<!-- Note: this file is copied to wiki from the main repo, edits on wiki page will be overridden -->
4+
5+
Welcome!
6+
Please see [the documentation](https://jupyter-docker-stacks.readthedocs.io/en/latest/) for help with
7+
using, contributing to, and maintaining the Jupyter Docker stacks images.
8+
9+
## Build History
10+
11+
This is an auto-generated index of information from the build system.
12+
In this index, you can find image tags, links to commits, and build manifests that describe the image.
13+
All the builds are grouped by year and then month.
14+
15+
Note: we only store the last 4500 manifest files because of GitHub limits.
16+
That's why old manifest files might not be available.
17+
If you want to clone this repo and access the Git history, use the following command: `git clone [email protected]:{REPOSITORY}.wiki.git`
18+
19+
In the tables below, each line represents:
20+
21+
- `YYYY-MM`: link to a page with a list of images built
22+
- `Builds`: # of times build workflow finished
23+
- `Images`: # of single platform images pushed
24+
- `Commits`: # of commits made and a GitHub link
25+
26+
<!-- Everything below is auto-generated, all manual changes will be erased -->
27+
<!-- YEAR_MONTHLY_TABLES -->

tagging/update_wiki.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
git = plumbum.local["git"]
1414

1515
LOGGER = logging.getLogger(__name__)
16+
THIS_DIR = Path(__file__).parent.resolve()
1617

1718

1819
def calculate_monthly_stat(
@@ -46,16 +47,16 @@ def calculate_monthly_stat(
4647
return builds, images, commits
4748

4849

49-
def regenerate_home_wiki_page(wiki_dir: Path) -> None:
50+
def generate_home_wiki_page(wiki_dir: Path, repository: str) -> None:
5051
YEAR_MONTHLY_TABLES = "<!-- YEAR_MONTHLY_TABLES -->\n"
5152

52-
wiki_home_file = wiki_dir / "Home.md"
53-
wiki_home_content = wiki_home_file.read_text()
53+
wiki_home_content = (THIS_DIR / "Home.md").read_text()
5454

5555
assert YEAR_MONTHLY_TABLES in wiki_home_content
5656
wiki_home_content = wiki_home_content[
5757
: wiki_home_content.find(YEAR_MONTHLY_TABLES) + len(YEAR_MONTHLY_TABLES)
5858
]
59+
wiki_home_content = wiki_home_content.format(REPOSITORY=repository)
5960

6061
YEAR_TABLE_HEADER = """\
6162
## {year}
@@ -65,7 +66,7 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
6566
"""
6667

6768
GITHUB_COMMITS_URL = (
68-
"[{}](https://github.com/jupyter/docker-stacks/commits/main/?since={}&until={})"
69+
f"[{{}}](https://github.com/{repository}/commits/main/?since={{}}&until={{}})"
6970
)
7071

7172
for year_dir in sorted((wiki_dir / "monthly-files").glob("*"), reverse=True):
@@ -95,7 +96,7 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
9596
year_total_line = f"| **Total** | {year_builds: <6} | {year_images: <6} | {year_commits_url: <95} |\n"
9697
wiki_home_content += year_total_line
9798

98-
wiki_home_file.write_text(wiki_home_content)
99+
(wiki_dir / "Home.md").write_text(wiki_home_content)
99100
LOGGER.info("Updated Home page")
100101

101102

@@ -159,6 +160,7 @@ def update_wiki(
159160
wiki_dir: Path,
160161
hist_lines_dir: Path,
161162
manifests_dir: Path,
163+
repository: str,
162164
allow_no_files: bool,
163165
) -> None:
164166
LOGGER.info("Updating wiki")
@@ -185,7 +187,7 @@ def update_wiki(
185187
year_month = build_history_line[3:10]
186188
update_monthly_wiki_page(wiki_dir, year_month, build_history_line)
187189

188-
regenerate_home_wiki_page(wiki_dir)
190+
generate_home_wiki_page(wiki_dir, repository)
189191
remove_old_manifests(wiki_dir)
190192

191193

@@ -211,6 +213,11 @@ def update_wiki(
211213
type=Path,
212214
help="Directory with manifest files",
213215
)
216+
arg_parser.add_argument(
217+
"--repository",
218+
required=True,
219+
help="Repository name on GitHub",
220+
)
214221
arg_parser.add_argument(
215222
"--allow-no-files",
216223
action="store_true",

0 commit comments

Comments
 (0)