在Windows和Macbook上自动更新和推送Hexo至GitHub
前言
Hexo自带deploy模块,网上也有很多大神分享各种各样的CI/CD方案,我没有想过写Blog需要这么复杂,而且Hexo已经很稳定了。我因为开始学习使用MacBook,所以逼着自己把之前用在Windows上的脚本用Python重新写了下,很简陋但也很好用,相信大家可以写出更加通用和优美的代码。
使用Powershell和Python自动化更新和推送Hexo静态Blog更新历史
2018年07月31日 - 初稿
阅读原文 - https://wsgzao.github.io/post...
Windows
./deploy_hexo.ps1# hexo g cd .\hexo hexo clean hexo g # del old files cd ..\wsgzao.github.io Remove-Item about,archives,categories,css,fancybox,font,img,index,js,page,post -recurse -force # deploy github Copy-Item ..\hexo\public\* .\ -recurse -force git add * git commit -m "mod" git push cd ..
MacBook
python3 deploy_hexo.pyimport os import sys import subprocess hexo = os.path.join(os.getcwd(), "hexo") wsgzao = os.path.join(os.getcwd(), "wsgzao.github.io") home = os.getcwd() print ("current directory %s" % home) os.chdir(hexo) retval = os.getcwd() print ("chdir to hexo %s" % retval) subprocess.call(['hexo clean'], shell=True) subprocess.call(['hexo g'], shell=True) os.chdir(wsgzao) retval = os.getcwd() print ("chdir to wsgzao %s" % retval) subprocess.call(['rm -rf about archives categories css fancybox font img index js page post'], shell=True) subprocess.call(['cp -rf ../hexo/public/* ./'], shell=True) subprocess.call(['git add *'], shell=True) subprocess.call(['git commit -m "mod"'], shell=True) subprocess.call(['git push'], shell=True)
相关推荐
JingLisen 2020-06-26
hzq0 2020-06-16
蓝亭书序 2020-06-04
Amzaing00 2020-05-11
hzq0 2020-05-10
乾坤一碼農 2020-05-10
gakki的二向箔 2020-05-07
hzq0 2020-05-05
hzq0 2020-05-05
只有代码的世界 2020-04-27
JingLisen 2020-04-23
gakki的二向箔 2020-04-07
89284553 2020-03-09
YULIU 2020-03-07
只有代码的世界 2020-03-04
hzq0 2020-02-21
只有代码的世界 2020-02-19
YULIU 2020-02-18