在 Travis-CI 中调用 EGO 自动更新博客

发布于 2023-03-18 22:20:17 字数 3086 浏览 4 评论 0

经过一番努力,总于把 EGO 改到可以无需人工介入自动更新博客了,现在只需要在 source branch 中加上两个文件:

.travis.yml

dist: xenial
language: generic

branches:
  only:
    - source

git:
  depth: false
  quiet: true

before_install:
 - git clone https://github.com/lujun9972/EGO ~/EGO
 - sudo add-apt-repository ppa:ubuntu-elisp/ppa -y
 - sudo apt-get update
 - sudo apt-get install emacs-snapshot -y
 - emacs-snapshot --version

script:
- git config --global core.quotepath false
- export REPO=$(git remote -v |grep fetch |head -n 1|awk '{print $2}')
- git clone -b source ${REPO} ~/source
- git clone -b master ${REPO} ~/web
- emacs-snapshot --batch -l ./auto_publish.el 

deploy:
  provider: pages
  skip_cleanup: true
  keep_history: true
  github_token: $GITHUB_TOKEN
  local_dir: /home/travis/web
  target_branch: master
  on:
    branch:
      - source

auto_publish.el

(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (when no-ssl (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
  ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  (when (< emacs-major-version 24)
    ;; For important compatibility libraries like cl-lib
    (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(package-refresh-contents)
(package-install 'mustache)
(package-install 'htmlize)

(setq load-path (cons  "~/EGO/" load-path))
(require 'log-edit)
(require 'htmlize)
(require 'ego)
(setq ego-project-config-alist
 `(("blog" :repository-directory "~/source" :site-domain "https://lujun9972.github.io/" :site-main-title "暗无天日" :site-sub-title "=============>随便,谢谢" :theme
    (emacs_love)
    :summary
    (("years" :year :updates 10)
     ("authors" :authors)
     ("tags" :tags))
    :source-browse-url
    ("Github" ,(getenv "REPO"))
    :personal-disqus-shortname "lujun9972" :personal-google-analytics-id "7bac4fd0247f69c27887e0d4e3aee41e" :ignore-file-name-regexp "README.org" :store-dir "~/web")))
(message "BEGIN TO AUTO PUBLIC")
(setq org-export-use-babel nil)
(setq debug-on-error t)
(ego-do-publication "blog" nil nil nil)

根据自己的需求更改 auto_publish.elego-project-config-alist 的配置。然后根据 这里步骤 创建一个 repo 权限的 github token,再为 travis-ci 中的仓库添加一个名为 GITHUB_TOKEN 的变量,值就是新创建的 github token 就可以了。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

列表为空,暂无数据

关于作者

多情癖

暂无简介

0 文章
0 评论
671 人气
更多

推荐作者

柒七

文章 0 评论 0

今天小雨转甜

文章 0 评论 0

〃温暖了心ぐ

文章 0 评论 0

TangBin

文章 0 评论 0

狼性发作

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击“接受”或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文