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了

相关推荐
Jiude5 小时前
AI 写代码太快之后,团队协作反而更难了
人工智能·架构·github
2401_876964139 小时前
27考研余炳森概率论|喻老李良2027资料网课
windows·git·考研·svn·eclipse·github·概率论
AhriProGramming10 小时前
GitHub开源项目推荐-1:pyd_packer
github
独自归家的兔11 小时前
AI界的 GitHub?Hugging Face 全面解析
人工智能·github
逛逛GitHub13 小时前
GitHub 上刚开源的国产 3D 高斯浏览器,杭州六小龙给力啊。
github
code_li14 小时前
免费服务器指南:GitHub Pages搭建静态网站全攻略
github·部署·免费服务器
阿里嘎多学长16 小时前
2026-05-28 GitHub 热点项目精选
开发语言·程序员·github·代码托管
小小程序员mono17 小时前
模型进入「日更时代」:GPT-5.6 泄露、Claude 4.8 逼近、Gemini 3.5 上线、国产杀疯了摘要
人工智能·重构·开源·github
Larcher17 小时前
「Codex + DeepSeek 用户请进:你的对话记录是不是也卡到想砸键盘?」
人工智能·github·编程语言
程序员柒叔18 小时前
Dify 一周动态-2026-W22
人工智能·大模型·github·agent·知识库·dify