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

关于在CI部署的站点中文章更新时间的问题 #4752

Closed
2 tasks done
MCSeekeri opened this issue Aug 10, 2021 · 4 comments
Closed
2 tasks done

关于在CI部署的站点中文章更新时间的问题 #4752

MCSeekeri opened this issue Aug 10, 2021 · 4 comments

Comments

@MCSeekeri
Copy link

Check List

Please check followings before submitting a new feature request.

  • I have already read Docs page
  • I have already searched existing issues

Feature Request

在目前的Hexo版本中,如果使用诸如Github Action的CI工具部署站点,那么post.updated这一项似乎会有些问题...
如果设置为mtime,那么所有文章的更新时间是Action部署站点的时间,而如果设置为date,那就会保持文章创建时间不变。
我个人希望即使是使用Action部署,Hexo仍然能够清晰的区分发布时间和更新时间...比如读取Git仓库的提交记录来判断更新时间。
目前现有的处理方法...比如手动添加updated或者手动更改date都太过繁琐,希望诸位大佬能够提供解决方案...

Others

@MCSeekeri
Copy link
Author

@SukkaW 苏卡卡大佬有没有什么解决方案...?

@jiangtj
Copy link
Member

jiangtj commented Aug 16, 2021

https://theme-next.js.org/docs/getting-started/deployment.html#Continuous-Integration

# Restore last modified time
"git ls-files -z | while read -d '' path; do touch -d \"$(git log -1 --format=\"@%ct\" \"$path\")\" \"$path\"; done"

image

@MCSeekeri
Copy link
Author

https://theme-next.js.org/docs/getting-started/deployment.html#Continuous-Integration

# Restore last modified time
"git ls-files -z | while read -d '' path; do touch -d \"$(git log -1 --format=\"@%ct\" \"$path\")\" \"$path\"; done"

image

很抱歉我实在是不知道如何操作...
我尝试把命令加入到Github Action的yml文件中,但出现了报错,我推测是因为Travis CI和Github Action的yml有些微妙的差别...

@SlieFamily
Copy link

是github检出操作(checkout)默认是浅拷贝的问题。当然也同样要用到上面那位老哥给的命令,但是对于github要进行适当的格式调整。
调整如下:
git ls-files -z | while read -d '' path; do touch -d $(git log -1 --format="@%ct" "$path") "$path"; done
而checkout部分,需要添加深拷贝选择:
JR_6X_G$OJ2~I8QL9V 96AK

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

No branches or pull requests

3 participants