Skip to content

Commit cc4f18a

Browse files
committed
Simplify the publishing process.
Renamed the tool script.
1 parent 4491c82 commit cc4f18a

File tree

5 files changed

+37
-45
lines changed

5 files changed

+37
-45
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,24 @@ By deploying the site in this way, you're allowed to push the source code direct
173173
|User or Organization | `<username>.github.io`|
174174
|Project| Any one except `<username>.github.io`, let's say `project`|
175175

176-
**2**. Commit the changes of the repo first, then run the initialization script:
176+
**2**. Commit the changes of the repo first, then run the publish script:
177177

178-
```terminal
179-
$ bash tools/init.sh
178+
```console
179+
$ bash tools/publish.sh
180180
```
181181

182-
>**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.
182+
> 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.
183183
184-
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:
184+
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:
185185

186186
```terminal
187187
[INFO] Success to update lastmod for 4 post(s).
188188
[INFO] Succeed! 3 category-pages created.
189189
[INFO] Succeed! 4 tag-pages created.
190-
[Automation] Updated the Categories, Tags, Lastmod for post(s).
191-
11 files changed, 46 insertions(+), 3 deletions(-)
192-
...
193-
Updated the Categories, Tags, Lastmod for post(s).
190+
[INFO] Published successfully!
194191
```
195192

196-
**3**. Push the changes to `origin/master` then go to GitHub website and enable GitHub Pages service for the repo.
193+
**3**. Go to GitHub website and enable GitHub Pages service for the repo.
197194

198195
**4**. Check it out:
199196

_posts/2019-08-08-write-a-new-post.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ tag: TAG_NAME # e.g. bee
7373
---
7474
```
7575

76-
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 }}).
76+
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 }}).
7777

7878
## Last modified date
7979

@@ -87,7 +87,7 @@ The last modified date of a post is obtained according to its latest git commit
8787
...
8888
```
8989

90-
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.
90+
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.
9191

9292
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.
9393

_posts/2019-08-09-getting-started.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,28 +138,24 @@ By deploying the site in this way, you're allowed to push the source code direct
138138
|User or Organization | `<username>.github.io`|
139139
|Project| Any one except `<username>.github.io`, let's say `project`|
140140

141-
**2**. Commit the changes of the repo first, then run the initialization script:
141+
**2**. Commit the changes of the repo first, then run the publish script:
142142

143143
```console
144-
$ bash tools/init.sh
144+
$ bash tools/publish.sh
145145
```
146146

147147
> 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.
148148
149-
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:
149+
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:
150150

151151
```terminal
152152
[INFO] Success to update lastmod for 4 post(s).
153153
[INFO] Succeed! 3 category-pages created.
154154
[INFO] Succeed! 4 tag-pages created.
155-
[Automation] Updated the Categories, Tags, Lastmod for post(s).
156-
11 files changed, 46 insertions(+), 3 deletions(-)
157-
...
158-
Updated the Categories, Tags, Lastmod for post(s).
155+
[INFO] Published successfully!
159156
```
160157

161-
162-
**3**. Push the changes to `origin/master` then go to GitHub website and enable GitHub Pages service for the repo.
158+
**3**. Go to GitHub website and enable GitHub Pages service for the repo.
163159

164160
**4**. Check it out:
165161

docs/README_zh-CN.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,21 @@ $ bash tools/run.sh
177177
**2**. 提交本地更改,然后运行:
178178

179179
```console
180-
$ bash tools/init.sh
180+
$ bash tools/publish.sh
181181
```
182182

183183
>****: *最后更新* 列表根据文章的 git 修改记录生成,所以运行前先把 `_posts` 目录的修改提交。
184184
185-
它会自动生成文章的 *最后修改日期**分类 / 标签* 页面,并自动提交一个 commit。输出日志类似如下:
185+
它会自动生成文章的 *最后修改日期**分类 / 标签* 页面,并自动提交一个 commit 并推送到 `origin/master` 。输出日志类似如下:
186186

187187
```terminal
188188
[INFO] Success to update lastmod for 4 post(s).
189189
[INFO] Succeed! 3 category-pages created.
190190
[INFO] Succeed! 4 tag-pages created.
191-
[Automation] Updated the Categories, Tags, Lastmod for post(s).
192-
11 files changed, 46 insertions(+), 3 deletions(-)
193-
...
194-
Updated the Categories, Tags, Lastmod for post(s).
191+
[INFO] Published successfully!
195192
```
196193

197-
198-
**3**. 推送到 `origin/master` 然后到 GitHub 网页为该项目开启 Pages 服务。
194+
**3**. 到 GitHub 网页为该项目开启 Pages 服务。
199195

200196
**4**. 网站将运行在:
201197

tools/init.sh renamed to tools/publish.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
#
3-
# Initial the Categories/Tags pages and Lastmod for posts.
3+
# Initial the Categories/Tags pages and Lastmod for posts and then push to remote
4+
#
45
# v2.0
56
# https://github.com/cotes2020/jekyll-theme-chirpy
67
# © 2019 Cotes Chung
@@ -15,19 +16,13 @@ LASTMOD=false
1516
WORK_DIR=$(dirname $(dirname $(realpath "$0")))
1617

1718
check_status() {
18-
local _watching_dirs=(
19-
"_post"
20-
"_data")
21-
22-
for i in "${!_watching_dirs[@]}"
23-
do
24-
local _dir=${_watching_dirs[${i}]}
25-
if [[ ! -z $(git status $_dir -s) ]]; then
26-
echo "Warning: Commit the changes of the directory '$_dir' first."
27-
git status -s | grep $_dir
28-
exit 1
29-
fi
30-
done
19+
local _change=$(git status . -s)
20+
21+
if [[ ! -z ${_change} ]]; then
22+
echo "Warning: Commit the changes of the changes first:"
23+
echo "$_change"
24+
exit 1
25+
fi
3126
}
3227

3328

@@ -72,12 +67,17 @@ commit() {
7267

7368
if [[ $CATEGORIES = true || $TAGS = true || $LASTMOD = true ]]; then
7469
msg+=" for post(s)."
75-
git commit -m "[Automation] $msg"
70+
git commit -m "[Automation] $msg" -q
7671
else
7772
msg="Nothing changed."
7873
fi
7974

80-
echo $msg
75+
}
76+
77+
78+
push() {
79+
git push origin master -q
80+
echo "[INFO] Published successfully!"
8181
}
8282

8383

@@ -90,6 +90,9 @@ main() {
9090
update_files
9191

9292
commit
93+
94+
push
9395
}
9496

97+
9598
main

0 commit comments

Comments
 (0)