Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host translations in gitbook, using monorepo approach #578

Merged
merged 24 commits into from
Aug 27, 2023
Merged

Conversation

spier
Copy link
Member

@spier spier commented Aug 24, 2023

The current approach for hosting the translations of our patterns is brittle.
As each book needs a custom .gitbook.yaml configuration, we have a script that copies the file to the root of the repo, depending on which book we want to render. That in turn also leads to the need for longstanding branches like book-ja, book-zh, etc.

All of this leads to various issues though, and the deployment of new versions of the book is still largely manual, which effectively means that we rarely do it :( See an example of that here: #493

Requirements

  • automatically publish the latest translations, once they are merged into main
  • don't change any of the URLs in the existing books (don't have to deal with redirects etc) - or a bit softer: change as few URLs as possible

Solution: monorepo configuration

In the meantime gitbook has created a configuration option to host multiple gitbooks from monorepos.

In this PR we are trying out how that works, and if it is an approach that would be better suited for hosting our translations.

How it works:

  • create one gitbook space for English and each translation (e.g. we would have 3 spaces right now: English, Japanese, Chinese)
  • set the "project directory" of that space to book/jp (these folders contain the custom content and configuration files for the specific book - in this example for the Japanese book)
  • that project directory contains a .gitbook.yaml, which points to the content for the given book
  • the pattern files can stay where they are (e.g. for en in patterns/... and for the translation in translations/jp/...

TODO

  • test on a gitbook collection, isolated from Production
  • adapt documentation - e.g. book/en/README.md, translation/README.md
  • adapt automation - .github/workflows/book.yaml - on any push to main, regenerate the TOCs for all books
  • adapt configuration (e.g. branch protection rules are no longer needed for book-jp)
  • merge this PR (so that we can deploy the book and all translations from main, using the new monorepos approach)
  • (IMMEDIATELY after merge) deploy to Production (requires a change to config of the git-sync in gitbook. see here) - we need to do this immediately because gitbook won't build correctly from the new main branch any more, using the old configuration
  • merge main into #InnerSource patterns book translation into Brazilian Portuguese #577 to prepare the monorepo configuration for the new Brazilian Portuguese translation
  • cleanup: remove branches book-* and PRs/issues that are now obsolete

@spier spier added (Self-) Hosting Everything around artifact rendering and presentation. Type - Translation Translating patterns into other languages labels Aug 24, 2023
@spier
Copy link
Member Author

spier commented Aug 24, 2023

In early tests of this, I saw something that looked like a bug:

  • ✅ The links in the menu work correctly.
  • ❌ However when clicking on the links hosted at /toc (toc.md) the links lead to the .md files in our GitHub repo, rather than to the rendered pages in gitbook.

It looks like the issue somehow resolved itself though.

@spier spier changed the title Host translations, using monorepo approach Host translations in gitbook, using monorepo approach Aug 24, 2023
@spier spier marked this pull request as ready for review August 26, 2023 22:43
@spier
Copy link
Member Author

spier commented Aug 27, 2023

Notes for how to configure the gitbook space.

  • go through all spaces (languages) one by one
    • delete existing git syn
    • reconfigure git sync
      • set branch to main (for all spaces)
      • set project directory to book/en/ for English, book/ja/ for Japanese etc
    • don't change any other configuration of the space (e.g. Google Analytics or similar). those should be correct as they are.

@spier
Copy link
Member Author

spier commented Aug 27, 2023

Merging to main, so that I can deploy to Production.

@spier spier merged commit 6fe18ea into main Aug 27, 2023
9 checks passed
@spier spier deleted the monorepo-test branch August 27, 2023 13:24
rmarting pushed a commit to rmarting/InnerSourcePatterns that referenced this pull request Feb 29, 2024
…mons#578)

* Remove the main gitbook yaml file. Need to be sure that config is picked up from subfolders.
* Change config of the en book
* Change config of the ja book
* Change config of the zh book
* Generate the TOCs for all books in a GHA matrix build
* Change commit messsage in book.yaml workflow run to make clear which file was changed and why
* Improve documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Self-) Hosting Everything around artifact rendering and presentation. Type - Translation Translating patterns into other languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant