diff --git a/README.md b/README.md index 93eaebf..3c1a32e 100644 --- a/README.md +++ b/README.md @@ -173,27 +173,24 @@ By deploying the site in this way, you're allowed to push the source code direct |User or Organization | `.github.io`| |Project| Any one except `.github.io`, let's say `project`| -**2**. Commit the changes of the repo first, then run the initialization script: +**2**. Commit the changes of the repo first, then run the publish script: -```terminal -$ bash tools/init.sh +```console +$ bash tools/publish.sh ``` ->**Note**: The *Recent Update* requires the posts' latest git-log date, so make sure the changes in `_posts` have been committed before running this command. +> Please note that the *Recent Update* list requires the latest git-log date of posts, thus make sure the changes in `_posts` have been committed before running this command. -it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit. Its output is similar to the following log: +it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit, and then push to `origin/master`. Its output is similar to the following log: ```terminal [INFO] Success to update lastmod for 4 post(s). [INFO] Succeed! 3 category-pages created. [INFO] Succeed! 4 tag-pages created. -[Automation] Updated the Categories, Tags, Lastmod for post(s). - 11 files changed, 46 insertions(+), 3 deletions(-) - ... -Updated the Categories, Tags, Lastmod for post(s). +[INFO] Published successfully! ``` -**3**. Push the changes to `origin/master` then go to GitHub website and enable GitHub Pages service for the repo. +**3**. Go to GitHub website and enable GitHub Pages service for the repo. **4**. Check it out: diff --git a/_posts/2019-08-08-write-a-new-post.md b/_posts/2019-08-08-write-a-new-post.md index a0d337c..3e7929d 100644 --- a/_posts/2019-08-08-write-a-new-post.md +++ b/_posts/2019-08-08-write-a-new-post.md @@ -73,7 +73,7 @@ tag: TAG_NAME # e.g. bee --- ``` -With the increasing number of posts, the number of categories and tags will increase several times! If we still manually create these *category*/*tag* type files, it will obviously be a super time-consuming job, and it is very likely to miss some of them(i.e. when you click on the missing `category` or `tag` link from a post or somewhere, it will complain to you '404'). The good news is that we got a lovely script tool `_scripts/sh/create_pages.sh` to finish the boring task. Basically we will use it via `tools/init.sh` instead of running it separately. Check out its use case [here]({{ "/posts/getting-started/#option-1-built-by-github-pages" | relative_url }}). +With the increasing number of posts, the number of categories and tags will increase several times! If we still manually create these *category*/*tag* type files, it will obviously be a super time-consuming job, and it is very likely to miss some of them(i.e. when you click on the missing `category` or `tag` link from a post or somewhere, it will complain to you '404'). The good news is that we got a lovely script tool `_scripts/sh/create_pages.sh` to finish the boring task. Basically we will use it via `tools/publish.sh` instead of running it separately. Check out its use case [here]({{ "/posts/getting-started/#option-1-built-by-github-pages" | relative_url }}). ## Last modified date @@ -87,7 +87,7 @@ The last modified date of a post is obtained according to its latest git commit ... ``` -You can choose to create this file manually, but as you may notice, the better approach is to let it be automatically generated by a tool script. And `_scripts/sh/dump_lastmod.sh` was born for this! Similar to the another script `_scripts/sh/create_pages.sh` mentioned above, it is also be called from `tools/init.sh`, so it doesn't have to be used separately. +You can choose to create this file manually, but as you may notice, the better approach is to let it be automatically generated by a tool script. And `_scripts/sh/dump_lastmod.sh` was born for this! Similar to the another script `_scripts/sh/create_pages.sh` mentioned above, it is also be called from `tools/publish.sh`, so it doesn't have to be used separately. When some posts have been modified since their published date and also the file `_data/updates.yml` was created correctly, a list with the label **Recent Updates** will be displayed in the right panel of the desktop view, which records the five most recently modified articles. diff --git a/_posts/2019-08-09-getting-started.md b/_posts/2019-08-09-getting-started.md index 16f8ad3..7c4c4b4 100644 --- a/_posts/2019-08-09-getting-started.md +++ b/_posts/2019-08-09-getting-started.md @@ -138,28 +138,24 @@ By deploying the site in this way, you're allowed to push the source code direct |User or Organization | `.github.io`| |Project| Any one except `.github.io`, let's say `project`| -**2**. Commit the changes of the repo first, then run the initialization script: +**2**. Commit the changes of the repo first, then run the publish script: ```console -$ bash tools/init.sh +$ bash tools/publish.sh ``` > Please note that the *Recent Update* list requires the latest git-log date of posts, thus make sure the changes in `_posts` have been committed before running this command. -it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit. Its output is similar to the following log: +it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit, and then push to `origin/master`. Its output is similar to the following log: ```terminal [INFO] Success to update lastmod for 4 post(s). [INFO] Succeed! 3 category-pages created. [INFO] Succeed! 4 tag-pages created. -[Automation] Updated the Categories, Tags, Lastmod for post(s). - 11 files changed, 46 insertions(+), 3 deletions(-) - ... -Updated the Categories, Tags, Lastmod for post(s). +[INFO] Published successfully! ``` - -**3**. Push the changes to `origin/master` then go to GitHub website and enable GitHub Pages service for the repo. +**3**. Go to GitHub website and enable GitHub Pages service for the repo. **4**. Check it out: diff --git a/docs/README_zh-CN.md b/docs/README_zh-CN.md index f0bdbe3..1c62708 100644 --- a/docs/README_zh-CN.md +++ b/docs/README_zh-CN.md @@ -177,25 +177,21 @@ $ bash tools/run.sh **2**. 提交本地更改,然后运行: ```console -$ bash tools/init.sh +$ bash tools/publish.sh ``` >**注**: *最后更新* 列表根据文章的 git 修改记录生成,所以运行前先把 `_posts` 目录的修改提交。 -它会自动生成文章的 *最后修改日期* 和 *分类 / 标签* 页面,并自动提交一个 commit。输出日志类似如下: +它会自动生成文章的 *最后修改日期* 和 *分类 / 标签* 页面,并自动提交一个 commit 并推送到 `origin/master` 。输出日志类似如下: ```terminal [INFO] Success to update lastmod for 4 post(s). [INFO] Succeed! 3 category-pages created. [INFO] Succeed! 4 tag-pages created. -[Automation] Updated the Categories, Tags, Lastmod for post(s). - 11 files changed, 46 insertions(+), 3 deletions(-) - ... -Updated the Categories, Tags, Lastmod for post(s). +[INFO] Published successfully! ``` - -**3**. 推送到 `origin/master` 然后到 GitHub 网页为该项目开启 Pages 服务。 +**3**. 到 GitHub 网页为该项目开启 Pages 服务。 **4**. 网站将运行在: diff --git a/tools/init.sh b/tools/publish.sh similarity index 73% rename from tools/init.sh rename to tools/publish.sh index ec3d2fb..9378d61 100755 --- a/tools/init.sh +++ b/tools/publish.sh @@ -1,6 +1,7 @@ #!/bin/bash # -# Initial the Categories/Tags pages and Lastmod for posts. +# Initial the Categories/Tags pages and Lastmod for posts and then push to remote +# # v2.0 # https://github.com/cotes2020/jekyll-theme-chirpy # © 2019 Cotes Chung @@ -15,19 +16,13 @@ LASTMOD=false WORK_DIR=$(dirname $(dirname $(realpath "$0"))) check_status() { - local _watching_dirs=( - "_post" - "_data") + local _change=$(git status . -s) - for i in "${!_watching_dirs[@]}" - do - local _dir=${_watching_dirs[${i}]} - if [[ ! -z $(git status $_dir -s) ]]; then - echo "Warning: Commit the changes of the directory '$_dir' first." - git status -s | grep $_dir - exit 1 - fi - done + if [[ ! -z ${_change} ]]; then + echo "Warning: Commit the changes of the changes first:" + echo "$_change" + exit 1 + fi } @@ -72,12 +67,17 @@ commit() { if [[ $CATEGORIES = true || $TAGS = true || $LASTMOD = true ]]; then msg+=" for post(s)." - git commit -m "[Automation] $msg" + git commit -m "[Automation] $msg" -q else msg="Nothing changed." fi - echo $msg +} + + +push() { + git push origin master -q + echo "[INFO] Published successfully!" } @@ -90,6 +90,9 @@ main() { update_files commit + + push } + main