最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】写Makefile实现commit提交文件到github.io仓库

Git crifan 4217浏览 0评论

现在已有Makefile去实现:用gitbook生成的website,pdf等多种文件格式,且可以用rsync上传到远程自己的服务器上:

且另外也需要手动拷贝生成的多种格式文件到github.io的代码仓库:

使得网页可以在github.io中也能看:

现在希望实现:

给Makefile中添加target,实现自动话:

把gitbook生成的多种文件拷贝到本地的git仓库中

再去git add 和git commit

最后git push到github.io代码仓库

现在先去找找:

makefile中如何写自动化git add commit push

makefile git add commit push

git add, commit and push commands in one? – Stack Overflow

7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook

make – Git commit from within a Makefile – Unix & Linux Stack Exchange

这个不错,传递参数:

git:

    git commit -m “$m

make git m=”My comment”

git add, commit and push commands in one? – Stack Overflow

makefile中用函数,貌似效果不错

Makefile 函数

跟我一起写Makefile:使用函数 – Ubuntu中文

Makefile中自定义函数的调用 – MyEyes – 博客园

Makefile 常用函数表 (转) – CSDN博客

跟我一起写 Makefile(九) – CSDN博客

Makefile中的wildcard用法 – CSDN博客

三、Makefile文件的语法 · Make 命令教程 · 看云

此处也要先去搞懂:

【已解决】rsync如何同步本地的文件夹

再去搞懂:

【已解决】Makefile中如何实现make时给变量传递参数如果没传用默认值

【总结】

如此,用:

################################################################################

# Commit to github

################################################################################

m ?= “1. update book $(BOOK_NAME)”

GITHUB_IO_PATH=/Users/crifan/dev/dev_root/github/github.io/crifan.github.io

## Commit generated files to github io

commit: all

  rsync -avzh –progress –stats –delete –force $(OUTPUT_PATH) $(GITHUB_IO_PATH)

  cd $(GITHUB_IO_PATH) && \

  pwd && \

  ls -la && \

  git status && \

  git add $(BOOK_NAME)/* && \

  git status && \

  git commit -m $(m) && \

  git status && \

  git push && \

  cd $(CURRENT_DIR) && \

  pwd

即可实现可以自动把此处的:

http_summary这个gitbook,在

make all

所生成的OUTPUT_PATH中的website,pdf,epub,mobi的所有文件,都rsync同步拷贝到此处的

/Users/crifan/dev/dev_root/github/github.io/crifan.github.io

然后分别的

git add http_summary/*

git commit -m “1. update book http_summary”

git push

去提交到github.io的仓库:

https://github.com/crifan/crifan.github.io

中了。

转载请注明:在路上 » 【已解决】写Makefile实现commit提交文件到github.io仓库

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.167 seconds, using 22.07MB memory