GitHub Workflow 和 Action 的一些注意事项

GitHub 的 workflow 和 action 存在一些注意事项,总结如下,以供参考

Workflow

on.issues.types

如果需要判断 label,不需要指定 opened,只需要指定 labeled,因为即使 label 是新建时设置的,也会触发 labeled

permissions

如果需要 checkout 当前 repo,需要添加 contents: write,否则会有权限问题

jobs.check.steps.env

如果需要 checkout 当前 repo,需要添加 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }},否则会有权限问题

Action

List repository issues

API 不仅返回 issues,也会返回 prs,默认 30 条每页,可以指定 labels 来过滤

List pull requests

API 返回所有 pull requests,默认 30 条每页,可以通过 per_pagepage 参数做分页处理,例如:

复制代码
const prs = [];
for (let page = 1; ; page++) {
  const { data } = await octokit.rest.pulls.list({
    ...context.repo,
    base: `refs/heads/main`,
    state: 'open',
    per_page: PER_PAGE,
    page,
  });
  prs.push(...data);
  if (data.length < PER_PAGE) {
    break;
  }
}

Get commit status

API 列出所有 contexts 对应的 state,可以过滤当前的 context

Create commit status

API 用于创建 commit 的 status,可指定 statecontextdescription(作为运行结果显示)

Setting

Require status checks

需要在 Branch protection rule 中的 Protect matching branches 下,勾选 Require status checks to pass before merging

Add required checks

需要将当前的 GitHub action 添加到 Status checks that are required

相关推荐
猫头虎1 小时前
2026全网最热Claude Skills工具箱,GitHub上最受欢迎的7大Skills开源AI技能库
langchain·开源·prompt·github·aigc·ai编程·agi
CoderJia程序员甲1 小时前
GitHub 热榜项目 - 日榜(2026-02-03)
git·ai·开源·llm·github
MicrosoftReactor3 小时前
技术速递|使用 GitHub Copilot SDK 将智能体集成到任何应用中
ai·github·copilot
极智-99615 小时前
GitHub 热榜项目-日榜精选(2026-02-02)| AI智能体、终端工具、视频生成等 | openclaw、99、Maestro等
人工智能·github·视频生成·终端工具·ai智能体·电子书管理·rust工具
樱花落海洋11119 小时前
GitHub DeskTop Can`t find URP项目
github
我的golang之路果然有问题20 小时前
使用 Hugo + GitHub Pages + PaperMod 主题 + Obsidian 搭建开发博客
golang·go·github·博客·个人开发·个人博客·hugo
codezzzsleep20 小时前
fuClaudeBackend:面向fuclaude的轻量后端代理 + Key 管理后台
ai·github·ai编程
kjzd12321 小时前
GitHub 热门项目趋势分析报告 (2026年2月2日)
github
LostSpeed21 小时前
git - github工程中不能包含大文件
git·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-02-02)
人工智能·ai·大模型·github·ai教程