260 words
1 minute
Automated Deployment
Automating GitHub Blog Deployment
# Workflow namename: Deploy Hexo to GitHub Pages
# Triggers: run on push to the main branch# `workflow_dispatch` lets you run it manually from the Actions pageon: push: branches: - main # the branch that contains your Hexo source workflow_dispatch:
# Job configurationjobs: build-and-deploy: # Runner runs-on: ubuntu-latest
# Steps steps: # Step 1: Checkout repository - name: Checkout 🛎️ uses: actions/checkout@v4 with: # `submodules: 'recursive'` handles the common case where a Hexo theme is a submodule submodules: 'recursive'
# Step 2: Set up Node.js - name: Set up Node.js 🟩 uses: actions/setup-node@v4 with: node-version: '24' # choose the Node.js version your project needs cache: 'npm' # cache npm dependencies to speed up future builds
# Step 3: Install dependencies - name: Install Dependencies 📦 run: npm install
# Step 4: Generate static files - name: Generate Static Files ⚙️ run: npx hexo generate # use `npx` to run the locally installed hexo-cli
# Step 5: Deploy to GitHub Pages - name: Deploy to GitHub Pages 🚀 uses: peaceiris/actions-gh-pages@v4 with: # Personal Access Token stored in repo Secrets personal_token: ${{ secrets.HEXO_DEPLOY_TOKEN }} # Target repository in the form <owner>/<repo> # e.g. 'your-username/your-username.github.io' external_repository: springkill/springkill.github.io # Hexo output directory is `public` by default publish_dir: ./public # Target branch to push publish_branch: master # for user/org pages, usually `main` or `master` # Commit author user_name: 'springkill' user_email: 'zzz.love.study@gmail.com' # Commit message commit_message: "🚀 Deploy from Hexo source repo @ ${{ github.sha }}" # Clean the target branch so only the latest build remains keep_files: false Automated Deployment
https://springkill.github.io/en/posts/自动部署/