vuepress
是个静态网站(博客)生成器,具备很是好的加载性能和搜索引擎优化,若是你使用过vue
的话,不妨试试,必定会让你爱不释手。vue
vuepress
提供了几种部署方法,有本地脚本
、Travis CI
、Netlify
,可是不能彻底知足个人需求。因此我开发了一个vuepress-deploy
的自动化部署工具。能够去GitHub Action
市场查看:https://github.com/marketplace/actions/vuepress-deploygit
<!-- more -->github
push
完代码后)GitHub Pages
域名,即支持自定义CNAME
在你项目仓库.github/workflows
目录下建立一个 .yml
文件,举例:vuepress-deploy.yml
。ubuntu
name: Build and Deploy on: [push] jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@master - name: vuepress-deploy uses: jenkey2011/vuepress-deploy@master env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} TARGET_REPO: username/repo TARGET_BRANCH: master BUILD_SCRIPT: yarn && yarn build BUILD_DIR: blog/.vuepress/dist/ CNAME: https://www.dachangxiaoyuan.top
上述配置的结果是:每次推送代码,将自动构建、部署到username/repo
的master
分支。就是这么简单~ide
若是不了解
github workflow
什么的,看下面的
详细教程
仓库:工具
对应状况与部署文件设置:性能
A
TO A:gh_pages
: deploy-to-current-repo-gh_pages.yml
A
TO B:master
: deploy-to-other-repo-master.yml
A
TO B:custom_branch
: deploy-to-other-repo-custom_branch.yml
效果查看:优化
A
TO A:gh_pages
: https://github.com/jenkey2011/vuepress-deploy-demo/tree/gh_pages A
TO B:master
:https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/master A
TO B:custom_branch
:https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/custom_branch 参数 | 含义 | 类型 | 是否必须 |
---|---|---|---|
ACCESS_TOKEN |
github的token | secrets |
是 |
TARGET_REPO |
目标仓库,例: jenkey2011/blog 。默认当前仓库 |
env |
否 |
TARGET_REPO |
目标仓库的分支,例:gh-pages 。默认 gh-pages |
env |
否 |
BUILD_SCRIPT |
构建脚本 例: yarn && yarn build |
env |
是 |
BUILD_DIR |
构建产物的目录 e.g.: blog/.vuepress/dist/ |
env |
是 |
CNAME |
Github Pages 站点别名 | env |
no |
点击你的头像 > Settings > Developer settings > Personal access tokens > Generate new token.
权限至少要勾选repo
,不清楚的,直接无脑全选就行~ 问题不大,不要慌。网站
你的vuepress项目源码仓库下 > Settings > Secrets, 建立ACCESS_TOKEN
, 值就填写你刚才建立的token,肯定。
在项目根目录下,建立.github/workflows
,而后再建立一个 .yml
文件,名字随便取,例:vuepress-deploy.yml
。
vuepress
: https://vuepress.vuejs.org/zh/ vuepress-deploy
: https://github.com/jenkey2011/vuepress-deploy 【原文地址】:使用vuepress-deploy自动部署vuepress静态网站至GitHub Pages