zola + github page,用 workflows 部署

之前的Zola都是本地build之后,再push到github上,这种方式很明显的弊端就是只能在本地编辑,而不能通过github编辑,再pull到本地,缺乏了灵活性。因此将zola用workflows来部署。

repo地址:https://github.com/King-Key/King-Key.github.io

主要就是增加workflows文件

完整的 .github/workflows/main.yml 文件

复制代码
name: Deploy website to Pages
on:
  # Runs on pushes targeting the default branch
  push:
    branches: [$default-branch]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

# Default to bash
defaults:
  run:
    shell: bash

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    env:
      ZOLA_VERSION: 0.19.2
    steps:
      - name: Install Zola
        run: |
          curl -sL https://github.com/getzola/zola/releases/download/v${ZOLA_VERSION}/zola-v${ZOLA_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar xz -C /usr/local/bin
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Build with Zola
        run: zola build
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./public

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

本地运行workflows

复制代码
gh workflow run main.yml

gh需要安装和登录验证

Mac环境下

复制代码
brew install  gh
gh login

可以选择跳转到浏览器进行登录验证,之后即可本地用命令运行workflows了

相关推荐
honsor8 分钟前
以太网温湿度传感器:RJ45直连机房的环境监控新方案
运维·网络·数据库·物联网·安全·云计算·github
小弥33 分钟前
GitHub今日热榜 | 2026-10-09:PS5 移植登顶,AI 创作工具占三席
github
小弥儿2 小时前
GitHub今日热榜 | 2026-10-08:逆向工程 MCP 登顶
学习·开源·github
shandianchengzi2 小时前
【记录】论文|创建 Anonymous 匿名 GitHub 仓库问题排查思路,以及新建匿名仓库至少要做的几件关键的事情
github·论文·科研
GPUStack4 小时前
一张 A800 80GB,跑通 Qwen-Image-2.1:GPUStack 部署、生成与图像编辑实战
人工智能·开源·github·vllm·大模型部署·gpustack
u1301305 小时前
GitHub 热榜项目:日榜(2026-10-08)
人工智能·github
高频因子挖掘机5 小时前
股票分钟 K 线为什么需要关注交易时段?——忽略这一点,回测可能从数据层就偏了
后端·github·api
miofly5 小时前
GitHub 日榜趋势速报 | 2026-10-09
开源·github
高频因子挖掘机5 小时前
批量请求和循环请求有什么本质区别?从量化数据管道重新理解 API 请求粒度
后端·github·api
最强小杰1 天前
Claude Opus 4.8 调用一直报 529 怎么办?同样请求换旧模型却正常——附 429/529 双桶退避代码
ai·github