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

相关推荐
hrx-@@1 小时前
DSH 插件开发到上架:完整实操手册
人工智能·语言模型·开源·github
一条泥憨鱼1 小时前
【从0开始学习计算机网络】| 邮件协议入门:SMTP、POP3、IMAP
linux·运维·计算机网络·github
lpfasd1233 小时前
2026年第36周GitHub趋势周报:Agent技能化、MCP工具化与AI工程化加速
人工智能·github
OpenTiny社区15 小时前
【直播分享】GenUI SDK 技术公开课第二讲 | GenuiChat 核心配置深度解析
前端·github
dong_junshuai15 小时前
每天一个开源项目#93 HyperFrames:4.69万星的 HTML 视频渲染框架
开源·html·github
峰向AI16 小时前
别再忍受杂乱的桌面了,这款窗口管理器让 Windows 也有平铺式操作
github
cnnews18 小时前
Ubuntu 编译 postmarketOS
linux·运维·arm开发·ubuntu·github·音视频
逛逛GitHub20 小时前
把最新开源的 2B 端侧模型接入 DeepSeek Harness,有点子神奇。
github
Boop_wu21 小时前
[redis] redis 快速入门
数据库·redis·github
m4Rk_1 天前
【论文阅读】Agent 记忆机制(63):SAMem——把经验记忆细化为带长期价值的状态—Thought
论文阅读·人工智能·学习·开源·github