Properly generate wiki home page in forks (#2226)

* Properly generate wiki home page in forks

* Better description
This commit is contained in:
Ayaz Salikhov
2025-02-20 00:01:55 +00:00
committed by GitHub
parent 332aac5ba7
commit e796b11ee1
4 changed files with 46 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ name: Download build manifests from GitHub artifacts and push them to GitHub wik
# This way we make sure we don't access wiki pages from several jobs simultaneously
env:
PUSH_TO_REGISTRY: ${{ (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && (github.ref == 'refs/heads/main' || github.event_name == 'schedule') }}
PUSH_TO_REGISTRY: ${{ github.ref == 'refs/heads/main' || github.event_name == 'schedule' }}
on:
workflow_call:
@@ -44,6 +44,7 @@ jobs:
--wiki-dir wiki/
--hist-lines-dir /tmp/jupyter/hist_lines/
--manifests-dir /tmp/jupyter/manifests/
--repository ${{ github.repository }}
shell: bash
- name: Push Wiki to GitHub 📤

View File

@@ -463,7 +463,7 @@ jobs:
- image: pytorch-notebook
variant: cuda12
needs: [aarch64-images-tag-push, x86_64-images-tag-push]
if: (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && !contains(github.event.pull_request.title, '[FAST_BUILD]')
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
merge-tags-fast:
uses: ./.github/workflows/docker-merge-tags.yml
@@ -478,19 +478,19 @@ jobs:
image: [docker-stacks-foundation, base-notebook]
variant: [default]
needs: [aarch64-images-tag-push-fast, x86_64-images-tag-push-fast]
if: (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && contains(github.event.pull_request.title, '[FAST_BUILD]')
if: contains(github.event.pull_request.title, '[FAST_BUILD]')
wiki-update:
uses: ./.github/workflows/docker-wiki-update.yml
needs: [aarch64-images-tag-push, x86_64-images-tag-push]
if: github.repository_owner == 'jupyter' && !contains(github.event.pull_request.title, '[FAST_BUILD]')
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
permissions:
contents: write
wiki-update-fast:
uses: ./.github/workflows/docker-wiki-update.yml
needs: [aarch64-images-tag-push-fast, x86_64-images-tag-push-fast]
if: github.repository_owner == 'jupyter' && contains(github.event.pull_request.title, '[FAST_BUILD]')
if: contains(github.event.pull_request.title, '[FAST_BUILD]')
permissions:
contents: write

27
tagging/Home.md Normal file
View File

@@ -0,0 +1,27 @@
# Jupyter Docker Stacks build manifests
<!-- Note: this file is copied to wiki from the main repo, edits on wiki page will be overridden -->
Welcome!
Please see [the documentation](https://jupyter-docker-stacks.readthedocs.io/en/latest/) for help with
using, contributing to, and maintaining the Jupyter Docker stacks images.
## Build History
This is an auto-generated index of information from the build system.
In this index, you can find image tags, links to commits, and build manifests that describe the image.
All the builds are grouped by year and then month.
Note: we only store the last 4500 manifest files because of GitHub limits.
That's why old manifest files might not be available.
If you want to clone this repo and access the Git history, use the following command: `git clone git@github.com:{REPOSITORY}.wiki.git`
In the tables below, each line represents:
- `YYYY-MM`: link to a page with a list of images built
- `Builds`: # of times build workflow finished
- `Images`: # of single platform images pushed
- `Commits`: # of commits made and a GitHub link
<!-- Everything below is auto-generated, all manual changes will be erased -->
<!-- YEAR_MONTHLY_TABLES -->

View File

@@ -13,6 +13,7 @@ from dateutil import relativedelta
git = plumbum.local["git"]
LOGGER = logging.getLogger(__name__)
THIS_DIR = Path(__file__).parent.resolve()
def calculate_monthly_stat(
@@ -46,16 +47,16 @@ def calculate_monthly_stat(
return builds, images, commits
def regenerate_home_wiki_page(wiki_dir: Path) -> None:
def generate_home_wiki_page(wiki_dir: Path, repository: str) -> None:
YEAR_MONTHLY_TABLES = "<!-- YEAR_MONTHLY_TABLES -->\n"
wiki_home_file = wiki_dir / "Home.md"
wiki_home_content = wiki_home_file.read_text()
wiki_home_content = (THIS_DIR / "Home.md").read_text()
assert YEAR_MONTHLY_TABLES in wiki_home_content
wiki_home_content = wiki_home_content[
: wiki_home_content.find(YEAR_MONTHLY_TABLES) + len(YEAR_MONTHLY_TABLES)
]
wiki_home_content = wiki_home_content.format(REPOSITORY=repository)
YEAR_TABLE_HEADER = """\
## {year}
@@ -65,7 +66,7 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
"""
GITHUB_COMMITS_URL = (
"[{}](https://github.com/jupyter/docker-stacks/commits/main/?since={}&until={})"
f"[{{}}](https://github.com/{repository}/commits/main/?since={{}}&until={{}})"
)
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:
year_total_line = f"| **Total** | {year_builds: <6} | {year_images: <6} | {year_commits_url: <95} |\n"
wiki_home_content += year_total_line
wiki_home_file.write_text(wiki_home_content)
(wiki_dir / "Home.md").write_text(wiki_home_content)
LOGGER.info("Updated Home page")
@@ -159,6 +160,7 @@ def update_wiki(
wiki_dir: Path,
hist_lines_dir: Path,
manifests_dir: Path,
repository: str,
allow_no_files: bool,
) -> None:
LOGGER.info("Updating wiki")
@@ -185,7 +187,7 @@ def update_wiki(
year_month = build_history_line[3:10]
update_monthly_wiki_page(wiki_dir, year_month, build_history_line)
regenerate_home_wiki_page(wiki_dir)
generate_home_wiki_page(wiki_dir, repository)
remove_old_manifests(wiki_dir)
@@ -211,6 +213,11 @@ if __name__ == "__main__":
type=Path,
help="Directory with manifest files",
)
arg_parser.add_argument(
"--repository",
required=True,
help="Repository name on GitHub",
)
arg_parser.add_argument(
"--allow-no-files",
action="store_true",