removeif / hexo-theme-icarus-removeif

Blog:https://removeif.github.io source code, modify from hexo-theme-icarus, simple and practical. Archieved !
65 stars 37 forks source link

使用 Travis 自动部署 #6

Closed EthanWng97 closed 4 years ago

EthanWng97 commented 4 years ago

您好, 我今下午尝试了利用 Travis 自动部署,但是每次部署之后打开网页都不能正常显示(一片空白),不知道什么原因,如果你有空的话,能帮忙尝试一下么,我感觉还挺方便的,利用自动部署就不用在本机 hexo g -d了。 谢谢

removeif commented 4 years ago

您好, 我今下午尝试了利用 Travis 自动部署,但是每次部署之后打开网页都不能正常显示(一片空白),不知道什么原因,如果你有空的话,能帮忙尝试一下么,我感觉还挺方便的,利用自动部署就不用在本机 hexo g -d了。 谢谢

@NavePnow 我照着网上的教程,最后一步推送代码时报错

remote: Invalid username or password.
fatal: Authentication failed for 'https://[secure]@github.com/removeif/removeif.github.io.git/'
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: remote: Invalid username or password.
fatal: Authentication failed for 'https://[secure]@github.com/removeif/removeif.github.io.git/'
    at ChildProcess.<anonymous> (/home/travis/build/removeif/blog_back_20190621/node_modules/hexo-util/lib/spawn.js:37:17)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:257:5)
Done. Your build exited with 0.

travis配置文件

# 指定语言环境
language: node_js
# 指定需要sudo权限
sudo: required
# 指定node_js版本
node_js:
  - 11.1.0
# 指定缓存模块,可选。缓存可加快编译速度。
cache:
  directories:
    - node_modules

# 指定博客源码分支,因人而异。hexo博客源码托管在独立repo则不用设置此项
#branches:
#  only:
#    - master

before_install:
  - npm install -g hexo-cli

# Start: Build Lifecycle
install:
  - npm install
  - npm install hexo-deployer-git --save

# 执行清缓存,生成网页操作
script:
  - hexo clean
  - hexo generate

# 设置git提交名,邮箱;替换真实token到_config.yml文件,最后depoy部署
after_script:
  - git config user.name "removeif"
  - git config user.email "980099577@163.com"
  # 替换同目录下的_config.yml文件中gh_token字符串为travis后台刚才配置的变量,注意此处sed命令用了双引号。单引号无效!
  - sed -i "s/gh_token/${GH_TOKEN}/g" ./_config.yml
  - cat ./_config.yml
  - hexo deploy

_config.yml配置

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
#  repo: https://github.com/removeif/remove.io.git
  repo: https://gh_token@github.com/removeif/removeif.github.io.git
  branch: master

感觉没问题了,实在不知道哪里的问题,你帮我看下哪里还漏了啥,是还要ssh密钥?

EthanWng97 commented 4 years ago

巧了,怕不是看的一篇,不过感觉配置有点少,应该是你的环境变量出问题了,我明天把我的配置发你。 BTW: 我的博客渲染出问题了 555 hexo server可以 但一部署网页看不到: nave.work 求救大佬(

removeif commented 4 years ago

巧了,怕不是看的一篇,不过感觉配置有点少,应该是你的环境变量出问题了,我明天把我的配置发你。 BTW: 我的博客渲染出问题了 555 hexo server可以 但一部署网页看不到: nave.work 求救大佬(

你的感觉是资源文件,js那些没部署上去,可以看下具体的自动部署的日志,应该有打印信息

EthanWng97 commented 4 years ago

如果是手动部署的呢,就hexo g -d,可以看么

removeif commented 4 years ago

如果是手动部署的呢,就hexo g -d,可以看么 @NavePnow 怎么手动部署,不是推上去后就自动部署了嘛

removeif commented 4 years ago

如果是手动部署的呢,就hexo g -d,可以看么

@NavePnow 我的可以了,之前的token有问题,重新生成了一个就好了。配置你可以参考下,部署后也能正常访问

# 指定语言环境
language: node_js
# 指定需要sudo权限
sudo: required
# 指定node_js版本
node_js:
  - 11.1.0
# 指定缓存模块,可选。缓存可加快编译速度。
cache:
  directories:
    - node_modules

# 指定博客源码分支,因人而异。hexo博客源码托管在独立repo则不用设置此项
#branches:
#  only:
#    - master

before_install:
#  - npm install -g hexo-cli

# Start: Build Lifecycle
install:
  - npm install
#  - npm install hexo-deployer-git --save

# 执行清缓存,生成网页操作
script:
  - hexo clean
  - hexo generate

# 设置git提交名,邮箱;替换真实token到_config.yml文件,最后depoy部署
after_script:
#  - git config user.name "removeif"
#  - git config user.email "removeif@163.com"
#  # 替换同目录下的_config.yml文件中gh_token字符串为travis后台刚才配置的变量,注意此处sed命令用了双引号。单引号无效!
#  - sed -i "s/gh_token/${GH_TOKEN}/g" ./_config.yml
#  - cat ./_config.yml
#  - ls
#  - pwd
#  - ls public
#  - hexo deploy
  - cd ./public
  - git init
  - git config user.name "removeif"
  - git config user.email "removeif@163.com"
  - git add .
  - git commit -m "TravisCI 自动部署"
  # Github Pages
  - git push --force --quiet "https://${GH_TOKEN}@github.com/removeif/removeif.github.io.git" master:master
EthanWng97 commented 4 years ago

我发现一个很奇怪的问题,本地 server之后,点击切换主题的时候,chrome会弹出一个 about:blank#blocked 的窗口,不知道是不是更新依赖之后的问题。感觉是因为这个而导致部署之后网站无法显示。

removeif commented 4 years ago

我发现一个很奇怪的问题,本地 server之后,点击切换主题的时候,chrome会弹出一个 about:blank#blocked 的窗口,不知道是不是更新依赖之后的问题。感觉是因为这个而导致部署之后网站无法显示。

@NavePnow 那不太清除了,多试下吧,Travis 自动部署是没问题的

EthanWng97 commented 4 years ago

好像找到问题了,我更新到了core-js@3.4.4之后,js路径找不到了,很奇怪

screenshot 2019-11-28 at 11 38 55

你知道怎么解决么 谢谢

EthanWng97 commented 4 years ago

感觉是没有自动接入 jsdelivr 导致的,我的配置文件和你的一样,也是 ,本地 hexo server因为在本地,所以就可以找到。。到云端就不行了。 (希望可以帮帮我,这几天被这个搞得有点绝望,真心感谢了)

removeif commented 4 years ago

感觉是没有自动接入 jsdelivr 导致的,我的配置文件和你的一样,也是 ,本地 hexo server因为在本地,所以就可以找到。。到云端就不行了。 (希望可以帮帮我,这几天被这个搞得有点绝望,真心感谢了)

也可以类似下面这样导入,换成你自己的git仓库,但是两种导入都没问题呀,那绝对路径也没毛病

EthanWng97 commented 4 years ago

如果是相对路径,那是怎么渲染成cdn的那个路径的呀。 我刚看了一眼 我的GitHub pages页面有js文件夹,不过是大写… 相对路径前面补全的地址是什么呀

removeif commented 4 years ago

如果是相对路径,那是怎么渲染成cdn的那个路径的呀。 我刚看了一眼 我的GitHub pages页面没有js这个文件夹。但…debug的时候的确有render js文件夹啊

可以试着模仿着这个来写, 但是这个cdn前缀地址是配置在_config.xml中, 其他引用的cdn地址和你自己引用的cdn地址可能不同,不能用同一个cdn地址 你直接就我这样写吧

EthanWng97 commented 4 years ago

好的嘞,我下午试一下

removeif commented 4 years ago

好的嘞,我下午试一下

@NavePnow 文件夹大小写敏感,改成大写JS就可以访问了,怎么会弄成大写啊

EthanWng97 commented 4 years ago
screenshot 2019-11-28 at 15 14 09

我也不知道诶,本地是小写的,但是渲染的时候就变大写了。

EthanWng97 commented 4 years ago

我靠,我终于知道为什么了。我有一个叫 JS 的tag,hexo 部署的时候把这两个合在一起了。 我服了

EthanWng97 commented 4 years ago

大哥,还有一个小问题,就是我修改之后问什么每次点 切换主题都有 about:blank#blocked 这个弹窗呀。

removeif commented 4 years ago

大哥,还有一个小问题,就是我修改之后问什么每次点 切换主题都有 about:blank#blocked 这个弹窗呀。

这个不太清楚,可能是啥冲突了

removeif commented 4 years ago

@NavePnow 这是我的 这是你的 你看下有什么不同,要学会对比代码,发现问题

EthanWng97 commented 4 years ago

咱俩代码是一样的,感觉是依赖包版本的问题?我在网上搜了一下 html disable target="_blank" ,在脚本后面多加上了 target="_blank" onclick='return false;' 就可以解决问题了,谢谢了!!!