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了

相关推荐
darkb1rd39 分钟前
clawsweeper:开源仓库维护自动化避坑实战指南
开源·github·好物分享
Alex艾力的IT数字空间2 小时前
大模型的“Think 模式”(思考模式)关闭的配置方式
人工智能·机器人·web3·github·开源软件·量子计算·开源协议
带娃的IT创业者3 小时前
GitHub Copilot 计费模式大变革:深度解析按量计费时代的技术实现与成本优化
github·copilot·ai编程·成本优化·github copilot·计费模式·按量计费
SiYuanFeng3 小时前
GitHub 仓库如何添加 Topic
github
豆豆16 小时前
网站管理系统大全:精选开源与商业CMS系统全面指南
github·cms·建站系统·建站·建站平台·内容管理系统·网站管理系统
用户794572239541318 小时前
一句话生成短视频:当 AI Skills 真正打通"创作流水线"
人工智能·github·ai编程
甄心爱学习19 小时前
【项目实训】法律文书智能摘要系统4
python·github·个人开发
河婆墟邓紫棋19 小时前
MIUI中的权限
android·github
OpenTiny社区20 小时前
GenUI SDK 生成式UI:六大开发特性详解,适配多种业务场景
前端·github·ai编程
Eloudy21 小时前
迁移带有 git lfs 功能的 github 仓库
git·github