-
Notifications
You must be signed in to change notification settings - Fork 387
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
MdBook hosted on Github Pages via Github Actions #98
Conversation
touch SUMMARY.md | ||
echo '# Summary' > SUMMARY.md | ||
echo "" >> SUMMARY.md | ||
for f in $(ls -tr | grep Chapter_ | sort -V); do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ls -tr | grep Chapter_ | sort -V
sorts the contents of the generated Summary.md
@@ -1,4 +1,9 @@ | |||
Update 28 November 2020: [Now also available in simplified Chinese](https://github.com/kumakichi/easy_rust_chs) thanks to [kumakichi](https://github.com/kumakichi)! | |||
## Update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circumvents the bug stated in this issue.
Hi! Thanks for the PR. This is all outside of my area of expertise and I see it's your first PR too, but then again it's to fix an issue. Do you want anyone to take a second look first or should I just merge it now? |
There shouldn't be a problem merging, given that there's no conflicts. It's your call. |
Sounds good! Here goes. |
Thanks for the merge! By the way, can you go to your repo's settings and activate GitHub Pages?
Sorry for the extra procedures. I need to make sure the online documentation is built from your repo, not mine. When you make further changes to your README.md, the online docs will automatically be updated as well. |
Hey, Looks like it worked: https://dhghomon.github.io/easy_rust/ |
Made a minor adjustment to README.md as explained in my reply to this.
createGithubPagesFromReadme.sh
is a fork ofcreateBookFromReadme.sh
. This new Bash script does not manually build the MdBook. It only reuses the original script's code which splits README.md into multiple chapters. One downside to the old script is that the chapters are not sorted in order. Hence,ls -tr | grep Chapter_ | sort -V
in line 38 ensures that the order is correct.Makefile now contains
github_pages
which executescreateGithubPagesFromReadme.sh
. Usage:make github_pages
Added
github-pages.yml
to.github/workflows
which configures Github Action to deploy a functional MdBook to Github Pages. If you're not acquainted with Github Actions, it's basically a continuous integration (CI) system similar to Travis, CircleCI etc. Essentially. the.yml
file instructs Github to install homebrew and coreutils which are dependencies for the splitting part, modify the scripts' permissions, runmake github_pages
, installs MdBook with this, runsmdbook build
, and finally deploys the docs to Github Pages.Note that the docs are placed in a new branch,
gh-pages
, as shown below. You can ignore this branch and leave it alone.Every time you push a change to the master branch, Github will automatically rebuild the docs which is pretty neat I think. Lastly, I added a badge in README.md so that you can easily see whether the build passes or vice versa.
In my fork, the built docs can be found at https://fongyoong.github.io/easy_rust/ which follows the format of https://<your_username>.github.io/<repo_name>.
If you can't find your own address, check the Settings of your repo to find the address. It should look like below:
However, I'm pretty sure it won't be an issue for you because the build times are usually around 1.5 minutes as shown below, and the book is pretty much complete for now.