【发布时间】:2019-08-23 10:24:12
【问题描述】:
我有以下设置:
NAS with GIT Server ---> Raspberry Pi with Jekyll ---> rsync to web-server
当 NAS 收到 Git 提交时,它会登录到我的 Pi 并激活脚本。这个脚本调用 Jekyll:
#!/usr/bin/env bash
MYDATE="$(date)"
PROJECT=website.git
REMOTE=username@username.example.com:html
NAS=username@nas.internal.example.com:333
# Log commit
logger "[GIT] Received commit in $PROJECT on $MYDATE"
# Change to git directory
cd ~/$PROJECT
if [ $? -ne 0 ]; then
logger "[GIT] Directory ~/$PROJECT does not exist on $MYDATE"
cd ..
exit
fi
# Pull new version from the server
git pull origin master #ssh://$NAS/~/$PROJECT
if [ $? -eq 0 ]; then
logger "[GIT] Successfully pulled new code from $PROJECT from NAS"
else
logger "[GIT] Unable to pull code from $PROJECT from NAS"
exit
fi
# Build Website
export JEKYLL_ENV=production
bundle exec jekyll build --incremental
if [ $? -eq 0 ]; then
logger "[GIT] Successfully built website from repository $PROJECT"
else
logger "[GIT] Jekyll returned an error on $PROJECT"
exit
fi
# Upload to hoster
rsync -aP -e ssh /home/username/$PROJECT/_site/ $REMOTE --delete
if [ $? -eq 0 ]; then
logger "[GIT] Successfully synced website $PROJECT with remote host"
else
logger "[GIT] Unable to sync folder of site $PROJECT with remote host"
exit
fi
从我的输出到日志和控制台,一切都井井有条,就返回码而言。 Jekyll 正在更新文章,但不会更新文章链接的概述。
这是我最新文章的头条:
---
layout: post
title: redacted
date: 2019-08-23 10:00:00
categories: gist
post_image: /images/cpp.jpg
excerpt: redacted
---
如您所见,这不是头等大事的问题。 /g/index.html中的概述页面,应该是我推新文章时更新的,是这样的:
<div style="padding-top: 2vh;"></div>
<div class="row">
{% for post in site.categories.gist limit:20 %}
<div class="col s12 m4 l4 dark-primary-color">
<div class="card">
<div class="card-image">
<img src="{{ site.url }}{{ post.post_image }}">
<span class="card-title"></span>
</div>
<div class="card-content default-primary-color primary-text-color">
<p class="length-limit">{{ post.excerpt }}</p>
</div>
<div style="padding-left: 0.5vw;" class="default-primary-color primary-text-color">
<a href="{{ site.url }}{{ post.url }}">Read</a>
</div>
<div style="padding-bottom: 2px;" class="default-primary-color"></div>
</div>
</div>
{% endfor %}
</div>
我不知道为什么 Jekyll 没有用新文章更新概述。如果我查看输出,您会看到它正在构建新文章,但没有更新应该更新的/g/index.html。
这是我推送新内容时得到的输出:
remote: * branch master -> FETCH_HEAD
remote: 39dea32..4f0ada5 master -> origin/master
remote: Merge made by the 'recursive' strategy.
remote: _posts/gist/2019-08-23-articlename.md | 2 +-
remote: 1 file changed, 1 insertion(+), 1 deletion(-)
remote: Configuration file: /home/username/project.git/_config.yml
remote: Source: /home/username/project.git
remote: Destination: /home/username/project.git/_site
remote: Incremental build: enabled
remote: Generating...
remote: done in 7.49 seconds.
remote: Auto-regeneration: disabled. Use --watch to enable.
remote: Welcome to the lima-city SSH service.
【问题讨论】: