惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园_首页
U
Unit 42
T
Tailwind CSS Blog
G
GRAHAM CLULEY
F
Full Disclosure
V
Vulnerabilities – Threatpost
T
Tenable Blog
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
P
Privacy International News Feed
K
Kaspersky official blog
Scott Helme
Scott Helme
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
有赞技术团队
有赞技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
LINUX DO - 最新话题
Recorded Future
Recorded Future
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
The GitHub Blog
The GitHub Blog
Cisco Talos Blog
Cisco Talos Blog
SecWiki News
SecWiki News
P
Proofpoint News Feed
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
罗磊的独立博客
S
Security Affairs
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
美团技术团队
Simon Willison's Weblog
Simon Willison's Weblog
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
Visual Studio Blog

ThinkAlone

JavaCard 上手 灵车!开创! Step-CA 日常使用教程 灵上加灵:使用 Pico HSM 和 step-ca 自建一个CA 友善 FriendlyELEC NanoPC-T4 CPU跑分测试 CPU Benchmark 常见物品尺寸记录 树莓派5 Raspberry Pi 5 CPU跑分测试 CPU Benchmark 鼎阳 SDS804X HD 示波器带宽与选件升级 OrangePi Zero3 CPU跑分测试 CPU Benchmark Canokey Canary上手 在2024年配置IPv6是什么怎样一种体验 用 Orange Pi Zero 搭建一台 Stratum 1 的 NTP 服务器 难绷的Zip与中文密码 OrangePi Zero CPU跑分测试 CPU Benchmark 使用 Docker 部署 zhenxun_bot(绪山真寻Bot) 在Docker中运行Klipper 如何优雅的跳过/禁止Steam更新你的游戏 使用 GitHub Actions 自动部署Hexo 使DockerHub的Autobuild自动构建ARM/其他 架构的镜像 CoffeeMiner:劫持WiFi网络接入设备进行“挖矿”的框架
使用 Travis CI 自动构建 Hexo 博客
Disappear9 · 2019-02-06 · via ThinkAlone

配置 GitHub 仓库

注意:以下全部操作尽量不要在Windows系统下操作
建立一个source分支,放入scaffolds source themes文件夹和_config.yml package.json文件

1
2
3
4
5
6
7
8
mkdir source
cd source
git init
git remote add origin [email protected]:Disappear9/disappear9.github.io.git
git checkout --orphan source
git add .
git commit -m "Initial commit"
git push origin source:source

创建 .travis.yml

1
2
language: node_js
node_js: stable

配置 Travis CI

用Github登录并且关联项目

配置Deploy keys

让Travis CI可以push到你的仓库

生成一个 ssh 密钥对:

1
$ ssh-keygen -t ed25519 -f travis.key

把travis.key.pub中的内容粘贴到Deploy keys

加密私匙

总不能把私匙直接放项目里把?
下面第一个坑来了:
我们需要安装 Travis 的命令行工具

1
2
$ sudo apt install ruby
$ sudo gem install travis

瞬间报错

1
2
ERROR:  Error installing ffi:
ERROR: Failed to build gem native extension.

Google了一圈,缺依赖,安上:

1
apt install ruby-dev curl

好了,能正常运行了
登录 Travis 并加密文件

1
2
3
4
# 如果是私有项目要加 --pro 参数
$ travis login --auto
# 加密完成后会在当前目录下生成 travis.key.enc 文件
$ travis encrypt-file travis.key -add

如果使用Windows系统,到这一步就会各种报错,官方甚至直接把这条写进了文档,说明不要在Windows系统下操作

1
2
Caveat #
There is a report of this function not working on a local Windows machine. Please use the WSL (Windows Subsystem for Linux) or a Linux or macOS machine

加密完成后把travis.key.enc放进travis文件夹,查看.travis.yml会发现多了这样一行

1
2
openssl aes-256-cbc -K $encrypted_************_key -iv $encrypted_************_iv 
-in .travis/travis.key.enc -out ~/.ssh/id_rsa -d

其中的$encrypted_************_keyiv应该会被自动添加到Travis的环境变量
然而在我这里并没有

然后就是第二个坑
你需要在运行$ travis encrypt-file travis.key -add时加上 –debug参数,这样工具就会打印出API日志,其中value长度为32位的是iv,更长的是key,然后手动把他们加入到Travis的环境变量(添加的时候不要把前面的$符号打进去,不然又是报错)(手贱这一下我调了半天没找到错误在那……)

编写 .travis.yml

.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
language: node_js
node_js: stable
branches:
only:
- source

cache:
yarn: true
directories:
- node_modules
- themes

addons:
ssh_known_hosts:
- github.com

before_install:
- openssl aes-256-cbc -K $encrypted_************_key -iv $encrypted_************_iv -in travis/travis.key.enc -out ~/.ssh/id_ed25519 -d
- chmod 600 ~/.ssh/id_ed25519
- git config --global user.name "Disappear9"
- git config --global user.email "[email protected]"
- chmod +x travis/deploy.sh

install:
- yarn

script:
- hexo clean
- hexo generate

after_success:
- travis/deploy.sh

deploy.sh(放进travis文件夹)

deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
set -ev
export TZ='Asia/Shanghai'

git clone --depth=1 -b master [email protected]:Disappear9/disappear9.github.io.git .deploy_git

cd .deploy_git
git checkout master
mv .git/ ../public/
cd ../public

git add .
git commit -m "Site updated: `date +"%Y-%m-%d %H:%M:%S"`"
git push origin master:master --force

上面这些步骤做完后你的目录看起来应该是这样的

https://github.com/Disappear9/disappear9.github.io/tree/source
欢迎参考

完成后git push origin source:source 这样Travis ci就会开始构建了

参考链接:

https://blessing.studio/deploy-hexo-blog-automatically-with-travis-ci/
https://segmentfault.com/a/1190000013286548