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

推荐订阅源

L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
B
Blog
WordPress大学
WordPress大学
Project Zero
Project Zero
P
Palo Alto Networks Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
T
Tailwind CSS Blog
Forbes - Security
Forbes - Security
F
Full Disclosure
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News: Ask HN
Hacker News: Ask HN
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Fortinet All Blogs
Cisco Talos Blog
Cisco Talos Blog
G
Google Developers Blog
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
O
OpenAI News
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
IT之家
IT之家
U
Unit 42
腾讯CDC
S
Security Affairs
C
Cisco Blogs
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss

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 授权协议,转载请注明来源,谢谢!