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

MdBook hosted on Github Pages via Github Actions #98

Merged
merged 8 commits into from
Dec 25, 2020

Conversation

FongYoong
Copy link

  1. Made a minor adjustment to README.md as explained in my reply to this.

  2. createGithubPagesFromReadme.sh is a fork of createBookFromReadme.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.

  3. Makefile now contains github_pages which executes createGithubPagesFromReadme.sh. Usage: make github_pages

  4. 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, run make github_pages, installs MdBook with this, runs mdbook 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.

image


  1. 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.

  2. 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:

image


  1. For your info, Github imposes a limit on Actions. More info can be found here.
    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.

image


  1. This is actually my first pull request and there may be mistakes lying around. Thanks for drafting the book, it really eased my steps towards Rust. Cheers! 😄

touch SUMMARY.md
echo '# Summary' > SUMMARY.md
echo "" >> SUMMARY.md
for f in $(ls -tr | grep Chapter_ | sort -V); do
Copy link
Author

@FongYoong FongYoong Dec 22, 2020

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
Copy link
Author

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.

@Dhghomon
Copy link
Owner

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?

@FongYoong
Copy link
Author

There shouldn't be a problem merging, given that there's no conflicts. It's your call.

@Dhghomon
Copy link
Owner

Sounds good! Here goes.

@Dhghomon Dhghomon merged commit c31dd70 into Dhghomon:master Dec 25, 2020
@FongYoong
Copy link
Author

Thanks for the merge!

By the way, can you go to your repo's settings and activate GitHub Pages?

  1. Go to Settings:

image

  1. Scroll all the way down to GitHub Pages and change the settings as shown below:

image

  1. Reply to me the link of the published website.

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.

@Dhghomon
Copy link
Owner

Dhghomon commented Jan 1, 2021

Hey,

Looks like it worked: https://dhghomon.github.io/easy_rust/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants