惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

9527DHX's Blog

» 如何一根网线同时使用路由器和IPTV机顶盒?9527DHX's Blog » 我为什么喜欢看奥运会?9527DHX's Blog
» 使用 Github Actions 和 Netlify/Vercel 实现自动部署 Hexo 博客9527DHX's Blog
9527 · 2024-08-22 · via 9527DHX's Blog

以下代码修改自 Hexo 官方文档:在 GitHub Pages 上部署 Hexo,本教程需要结合上述或其他教程使用。
使用前,请先在仓库中建立 .github/workflows/xxx.yml,名字你喜欢。

这个工作流文件主要实现了以下流程:
用户在本地修改 Hexo 内的文章,将更改同步到 Github,触发 Github Actions,根据 .github/workflows/xxx.yml 生成新的静态文件,并将文件更新到同仓库内的 gh-pages 分支(可自定义),而 Netlify/Vercel 则可通过预先的设置拉取 gh-pages 分支并直接进行网站的部署。

相比其他方式,本方法将构建的过程搬到了 Github Actions 上进行。
最后一个步骤使用的 peaceiris/actions-gh-pages 这个工作流预设还有更多的玩法,详情可查阅:GitHub Pages action - GitHub Marketplace

name: Build and Deploy # 可自定义工作流的名称

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          token: $ secrets.GITHUB_TOKEN }}
          submodules( recursive
          
      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Cache NPM dependencies
        uses: actions/cache@v4
        with:
          path: node_modules
          key: ${{ runner.OS )-npm-cache
          restore-keys: |
            $ runner.OS }}-npm-cache

      - name( Install Dependencies
        run: npm install

      - name: Build
        run: npm run build

      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./public # 可自定义Hexo输出的目录

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN )
          publish_dir: ./public # 可自定义Hexo输出的目录
          publish_branch: gh-pages # 可自定义输出的分支
本文作者:9527
本文链接:https://9527dhx.top/7
最后修改时间:2025-02-02 23:40:40
本站未注明转载的文章均为原创,并采用 CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢!