Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
package

GitHub Action

Hexo Action

v1.0.0

Hexo Action

package

Hexo Action

Hexo CI/CD action for automating deployment

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Hexo Action

uses: sma11black/[email protected]

Learn more about this action in sma11black/hexo-action

Choose a version

GitHub Action - Hexo CI/CD :trollface:

View Action License: MIT

This Github Action automating hexo deployment workflow, to allow you to leverage GitHub Actions to publish your hexo site on Github Pages.

Usage✒️

Pre-requisites

Step 1: Setup Deploy keys and Secrets

The with portion of the workflow must be configured before the action will work. You can add these in the with section found in the example workflow below. Any secrets must be referenced using the bracket syntax and stored in the GitHub repositories Settings/Secrets menu. You can learn more about setting environment variables with GitHub actions here.

How to add your ssh key pair?🔑

  1. Run the following terminal command, replacing the email with one connected to your GitHub account.
ssh-keygen -t rsa -C "[email protected]"
  1. In Github Pages repo: Add the contents of the public key within your repositories deploy keys menu. You can find this option by going to Settings > Deploy Keys, you can name the public key whatever you want, but you do need to give it write access.
  2. In hexo source code repo: Add the contents of the private key to the Settings > Secrets menu as DEPLOY_KEY.

Step 2: Configure github workflows

Create a workflow .yml file in your .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.

Inputs

For more information on these inputs, see the API Documentation

  • user_name: Required The user name of your github account for deploying.
  • user_email: Required The user email of your github account for deploying.
  • deploy_key: Required The deploy key to access your GitHub Pages repository.

Outputs

For more information on these outputs, see the API Documentation for an example of what these outputs look like

  • notify: Deploy complate notification.

Example workflow - hexo deploy📝

On every push to this repo, generate hexo sites and publish on username.github.io repo.

name: Deploy

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    name: A job to deploy blog.
    steps:
    - name: Checkout
      uses: actions/checkout@v1
      with:
        submodules: true # Checkout private submodules(themes or something else).
    
    # Caching dependencies to speed up workflows. (GitHub will remove any cache entries that have not been accessed in over 7 days.)
    - name: Cache node modules
      uses: actions/cache@v1
      id: cache
      with:
        path: node_modules
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-node-
    - name: Install Dependencies
      if: steps.cache.outputs.cache-hit != 'true'
      run: npm install
    
    # Deploy hexo blog website.
    - name: Deploy
      id: deploy
      uses: sma11black/[email protected]
      with:
        deploy_key: ${{ secrets.DEPLOY_KEY }}
        user_name: your github username
        user_email: your github useremail
    # Use the output from the `deploy` step(use for test action)
    - name: Get the output
      run: |
        echo "${{ steps.deploy.outputs.notify }}"

Recommand Settings💊

Custom domain with CNAME

If your Github Pages needs to use a CNAME file to customize the domain name, put the CNAME file in the source directory, only then can hexo deploy push the CNAME file to the deployment repository.

Make your hexo repository private

Hide your hexo source repository from the public to protect your website.

Using submodule in your hexo repository

Add any hexo themes branch as gitmodules.

git submodule add https://github.com/theme-next/hexo-theme-next.git themes/next -b 87305b1

License ©️

The scripts and documentation in this project are released under the MIT License