Comments (6)
我在使用github actions将github private仓库的代码自动部署到github pages上,但这过程中发现个问题,无法写入更新时间到private仓库的lastGeneratePath.log里,请问是否有好的办法,github actions代码如下:
name: Blog CI/CD
on: [push, repository_dispatch]
jobs:
blog-cicd:
name: Hexo blog build & deploy
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
steps:
- name: Checkout codes
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: |
npm install hexo-cli -g
npm install yuque-hexo -g
npm install
npm run yuque
- name: Generate files
run: hexo generate
- name: Deploy blog
run: |
git clone "https://${{ secrets.GH_REF }}" deploy_git
mv ./deploy_git/.git ./public
cd ./public
git config user.name "xxx"
git config user.email "xxx"
git add .
git commit -m "GitHub Actions Auto Builder at $(date +'%Y-%m-%d %H:%M:%S')"
git push --force --quiet "https://${{ secrets.GH_TOKEN }}@${{ secrets.GH_REF }}" main:main
from yuque-hexo.
看不出来问题在哪,但是部署到githubpages有插件的,可以试一下以下流程
仓库分为博客源码仓库和GithubPages仓库
- 配置配置Git用户名邮箱
- yuque-hexo sync
- 上传代码到博客源码仓库
- hexo generate 生成静态文件
- 利用peaceiris/actions-gh-pages@v3 上传文章到GitHub Pages
- name: 上传文章到GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.SSH_PRIVATE_KEY }}
external_repository: LetTTGACO/LetTTGACO.github.io // 你的GH地址
publish_branch: master
publish_dir: ./public
commit_message: ${{ github.event.head_commit.message }} // 默认
from yuque-hexo.
至于第三步 推送代码到博客源码仓库。我也使用的插件
- name: 推送文章到仓库
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
from yuque-hexo.
参考我的部署配置
name: Deplo
on:
# 允许手动push触发
push:
branches:
- master
# 允许外部仓库事件触发
repository_dispatch:
types:
- start
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检查分支
uses: actions/checkout@master
- name: 安装node环境
uses: actions/setup-node@master
with:
node-version: "12.x"
- name: 缓存依赖
uses: actions/cache@v1
id: cache
with:
path: node_modules
key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}}
- name: 安装依赖
if: steps.cache.outputs.cache-hit != 'true'
run: |
export TZ='Asia/Shanghai'
npm install
- name: 拉取语雀的文章
env:
YUQUE_TOKEN: ${{ secrets.YUQUE_TOKEN }}
run: |
npm run yuque:sync // yuque-hexo sync
- name: 配置Git用户名邮箱
run: |
git config --global user.name "1874"
git config --global user.email "[email protected]"
- name: 提交yuque拉取的文章到GitHub源码仓库
run: |
echo `date +"%Y-%m-%d %H:%M:%S"` begin > time.txt
git add .
git commit -m "Refresh yuque json" -a
- name: 推送文章到仓库
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 生成静态文件
run: |
npm run hexo:clean // hexo clean
npm run hexo:build // hexo generate
- name: 上传文章到GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.SSH_PRIVATE_KEY }}
external_repository: LetTTGACO/LetTTGACO.github.io
publish_branch: master
publish_dir: ./public
commit_message: ${{ github.event.head_commit.message }}
from yuque-hexo.
我的意思是,每次从博客源码仓库用github actions部署到github pages仓库,actions里每次都必须拉取语雀所有文章,然后再重新生成到github pages吗?因为lastGeneratePath.log无法起作用...
from yuque-hexo.
我的意思是,每次从博客源码仓库用github actions部署到github pages仓库,actions里每次都必须拉取语雀所有文章,然后再重新生成到github pages吗?因为lastGeneratePath.log无法起作用...
不会啊,我的就是这么配置的,能正常提交的,lastGeneratePath.log写入我倒是没遇到过,可以看下日志。
from yuque-hexo.
Related Issues (20)
- 上传七牛云图床部分图片上次失败,无法准确定位到具体问题 HOT 1
- 用七牛云上传图片,但是图片损坏了,不知道那里出问题了 HOT 7
- 可以自动上传到又拍云 图床么 HOT 2
- 语雀图片转换失败 HOT 3
- 教程描述有待提升 HOT 5
- 请求添加自动分组功能 HOT 2
- 建议同步语雀文档的修改时间 HOT 4
- 最近发现自动上传到图床的图片大小都不正确,无法正常显示怎么排查? HOT 4
- 发现隔一段时间(一到两周)就部署失败,重置了yuque_token后正常 HOT 3
- 关于 adpater (hexo) is invalid. 的问题 HOT 11
- 自定义 front-matter 异常
- 语雀分享要会员了,可以出一个飞书的吗
- 是否可以保留hexo写博客的能力? HOT 2
- 图片替换失败
- yuque-hexo相关逻辑 HOT 1
- [WARNING] 检查图片信息时出错
- 现在没有会员咋设置token HOT 2
- 增加下载文件到 source/images 目录的支持 HOT 4
- use slug as permant_link title HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yuque-hexo.