Github Actions
生成 SSH Key
1
| ssh-keygen -t rsa -b 4096 -C "emal@gmail.com"
|
添加 Key 到 GitHub
公钥
仓库 –> Secrets –> Actions –> New repository secert
Name: HEXO_DEPLOY_KEY
Value: id_rsa.pub 的值
私钥
仓库 –> Settings –> Deploy keys –> Add deploy key
Name: HEXO_DEPLOY_PUB
Value: id_rsa 的值
使用
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 33 34 35 36 37 38 39 40 41 42 43
| name: Hexo Deploy
on: push: branches: - source
permissions: contents: write
jobs: build: runs-on: ubuntu-latest name: auto deploy steps: - name: Checkout Repository uses: actions/checkout@v4 with: ref: source
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "25"
- name: Generate Public Files run: | npm install npx hexo clean npx hexo generate
- name: Deploy Hexo uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: master publish_dir: ./public commit_message: ${{ github.event.head_commit.message }} user_name: 'yourname' user_email: 'yourname@mail.com'
|