diff --git a/.github/workflows/docker-wiki.yml b/.github/workflows/docker-wiki.yml new file mode 100644 index 00000000..2d5e3660 --- /dev/null +++ b/.github/workflows/docker-wiki.yml @@ -0,0 +1,48 @@ +name: Download manifest artifacts from GitHub, tag and push to DockerHub +# We're doing everything in one workflow on purpose +# This way we make sure we don't access wiki pages from several jobs simultaneously + +on: + workflow_call: + +jobs: + tag-push: + runs-on: ${{ inputs.runsOn }} + + strategy: + matrix: + image: ${{ fromJson(inputs.images) }} + + steps: + - name: Checkout Repo ⚡️ + uses: actions/checkout@v3 + - name: Create dev environment 📦 + uses: ./.github/actions/create-dev-env + + # To make this workflow easier to implement, we download all artifacts + # https://github.com/actions/download-artifact/issues/6 + - name: Download all artifacts 📥 + uses: actions/download-artifact@v3 + with: + path: /tmp/artifacts/ + - name: Display structure of downloaded files + run: ls - R + working-directory: /tmp/artifacts/ + shell: bash + + - name: Checkout Wiki Repo 📃 + uses: actions/checkout@v3 + with: + repository: ${{github.repository}}.wiki + path: wiki/ + + - name: Update wiki page 🏷 + run: python3 -m tests.update_wiki_page --wiki-dir wiki/ --artifacts-dir /tmp/artifacts/ + shell: bash + + - name: Push Wiki to GitHub 📤 + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.event_name == 'schedule' + uses: stefanzweifel/git-auto-commit-action@5804e42f86b1891093b151b6c4e78e759c746c4d # dependabot updates to latest release + with: + commit_message: "Automated wiki publish for ${{github.sha}}" + repository: wiki/ diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b7ac9776..dac9a2f9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,6 +10,7 @@ on: - ".github/workflows/docker-build-upload.yml" - ".github/workflows/docker-test.yml" - ".github/workflows/docker-tag-manifest-push.yml" + - ".github/workflows/docker-wiki.yml" - ".github/actions/create-dev-env/action.yml" - ".github/actions/load-image/action.yml" @@ -35,6 +36,7 @@ on: - ".github/workflows/docker-build-upload.yml" - ".github/workflows/docker-test.yml" - ".github/workflows/docker-tag-manifest-push.yml" + - ".github/workflows/docker-wiki.yml" - ".github/actions/create-dev-env/action.yml" - ".github/actions/load-image/action.yml" diff --git a/tagging/update_wiki_page.py b/tagging/update_wiki_page.py new file mode 100644 index 00000000..b163fd83 --- /dev/null +++ b/tagging/update_wiki_page.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. +import argparse +import logging +import shutil +from pathlib import Path + + +def update_wiki_page(wiki_dir: Path, artifacts_dir: Path) -> None: + home_wiki_file = wiki_dir / "Home.md" + file = home_wiki_file.read(home_wiki_file) + + build_history_line_files = artifacts_dir.rglob("**/*.txt") + build_history_lines = "\n".join( + hist_line_file.read_text() for hist_line_file in build_history_line_files + ) + TABLE_BEGINNING = "|-|-|-|\n" + file = file.replace(TABLE_BEGINNING, TABLE_BEGINNING + build_history_lines + "\n") + home_wiki_file.write(file) + + for file in artifacts_dir.rglob("**/*.md"): + shutil.copy(file, wiki_dir / file.name) + + +if __name__ == "__main__": + logging.basicConfig(level=logging.INFO) + + arg_parser = argparse.ArgumentParser() + arg_parser.add_argument( + "--wiki-dir", + required=True, + type=Path, + help="Directory for wiki repo", + ) + arg_parser.add_argument( + "--artifacts-dir", + required=True, + type=Path, + help="Directory to save history line", + ) + args = arg_parser.parse_args() + + update_wiki_page(args.wiki_dir, args.artifacts_dir)