前言
具体的教程百度一下有很多,个人主要使用action同时发布到github的pages 跟 阿里云的ftp上,因此将网络搜到的整合了一下,仅做备忘
目前效率还有点低,需要编译两遍,凑合能用,有空再去修改
yml文件代码
name: Deploy Hexo
on:
push:
branches:
- main # main 分支有 push 行为时就触发这个 action
jobs:
build-and-deploy:
name: Deploy To Github Pages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Build and Deploy
uses: MrSeaning/hexo-deploy-github-pages-action@master # 使用专门部署 Hexo 到 GitHub pages 的 action
env:
PERSONAL_TOKEN: ${{ secrets.HEXO_DEPLOY }} # secret 名
PUBLISH_REPOSITORY: ... # 公共仓库,格式:GitHub 用户名/仓库名
BRANCH: gh-pages # 分支,填 gh-pages 就行
PUBLISH_DIR: ./public # 部署 public 目录下的文件
web-deploy:
name: Deploy To AliYun FTP
runs-on: ubuntu-latest
steps:
- name: Get latest code
uses: actions/checkout@v2.3.2
- name: Use Node.js 12
uses: actions/setup-node@v2-beta
with:
node-version: '12'
- name: Build Project
run: |
npm install hexo-cli -g
npm install
hexo clean
hexo generate
- name: ? Sync files
uses: SamKirkland/FTP-Deploy-Action@4.0.0
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./public/
server-dir: ./htdocs/