SDYTO / SDYTO/senlin

2025-25

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
HTML
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

name: build Gmeek

on:
workflow_dispatch: # 手动触发
issues:
types: [opened, edited] # Issue 触发(新建/编辑 Issue 时自动生成博客)
schedule:
- cron: "0 16 * * *" # 定时触发(每天 UTC 16:00 = 北京时间 00:00)

jobs:
build:
name: Generate blog
runs-on: ubuntu-24.04
# 权限控制:仓库所有者或定时任务可触发
if: ${{ github.event.repository.owner.id == github.event.sender.id || github.event_name == 'schedule' }}
permissions: write-all # 全写权限(适配提交代码、创建目录)
steps:
- name: Checkout 本仓库代码
uses: actions/checkout@v4
with:
fetch-depth: 1 # 仅拉取最新代码,加快速度

  - name: Setup Pages 配置
    id: pages
    uses: actions/configure-pages@v4  # 适配 GitHub Pages

  - name: 安装依赖工具(jq)
    run: |
      sudo apt-get update && sudo apt-get install -y jq
      echo "====== 检查 config.json 文件 ======"
      if [ -f "config.json" ]; then
        cat config.json
      else
        echo "❌ 错误:未找到 config.json 文件,请确认仓库根目录存在该文件!"
        exit 1
      fi
      echo "====== 检查 config.json 结束 ======"

  - name: 配置 Python 环境
    uses: actions/setup-python@v5
    with:
      python-version: 3.8  # 兼容 Gmeek.py 的 Python 版本

  - name: 安装 Python 依赖
    run: |
      pip install --upgrade pip
      # 安装依赖(优先读取 requirements.txt,无则直接安装 requests)
      if [ -f "requirements.txt" ]; then
        pip install -r requirements.txt
      else
        pip install requests
      fi

  - name: 生成博客 HTML 文件
    run: |
      echo "====== 开始执行 Gmeek 生成脚本 ======"
      # 验证 Gmeek.py 是否存在
      if [ ! -f "Gmeek.py" ]; then
        echo "❌ 错误:未找到 Gmeek.py 主脚本,请确认仓库根目录存在该文件!"
        exit 1
      fi
      # 执行 Gmeek.py(传递 Token、仓库地址、Issue 编号)
      python Gmeek.py \
        ${{ secrets.GITHUB_TOKEN }} \
        ${{ github.repository }} \
        --issue_number '${{ github.event.issue.number || '' }}'
      echo "====== Gmeek 脚本执行完成 ======"

      # 验证生成结果(确保 docs/index.html 存在)
      echo "====== 验证生成产物 ======"
      if [ -f "docs/index.html" ]; then
        echo "✅ docs/index.html 生成成功,文件大小:$(du -sh docs/index.html | awk '{print $1}')"
        # 可选:打印前 5 行 HTML 确认结构
        echo "====== 首页 HTML 前 5 行 ======"
        head -n 5 docs/index.html
      else
        echo "❌ 错误:未生成 docs/index.html,请检查 Gmeek.py 执行日志!"
        exit 1
      fi

  - name: 提交生成的文件到本仓库
    run: |
      # 配置 Git 提交者信息
      git config --local user.name "${{ github.repository_owner }}"
      git config --local user.email "$(jq -r ".email" config.json)"

      # 添加所有变更文件(docs 目录、backup 目录、blogBase.json)
      git add docs/ backup/ blogBase.json 2>/dev/null || echo "部分文件未找到,跳过"
      # 提交(无变更则不报错)
      git commit -m '🎉auto update by Gmeek action (${{ github.sha }})' || echo "ℹ️ 无新内容需要提交"
      # 推送到当前分支
      git push origin ${{ github.ref }} || echo "ℹ️ 推送失败(可能无权限或无变更)"
      sleep 3

  - name: 上传 Pages 部署产物
    uses: actions/upload-pages-artifact@v3
    with:
      path: 'docs/.'  # 上传 docs 目录(包含 index.html)

deploy:
name: Deploy blog to GitHub Pages
runs-on: ubuntu-24.04
needs: build # 依赖 build 任务完成
permissions:
contents: write
pages: write
id-token: write # GitHub Pages 部署必需权限
concurrency:
group: "pages"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: 部署到 GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the workflow definition together with config.json, requirements.txt, and Gmeek.py. Check what the issue is intended to change, then verify whether the workflow can generate docs/index.html and deploy it to GitHub Pages; the issue needs a specific requested outcome before work can be considered done.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github-actions, html, python
Domain
ci-cd, devops
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.