You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub技术咨询:通过API更新Issues时如何跳过Workflow执行

How to Skip GitHub Workflow When Updating Issues via REST API

First off, you’re right that GitHub doesn’t have a native "skip workflow" flag specifically for issue events like it does for pushes/pull requests (with [skip ci] or similar). But there are a few reliable workarounds to prevent your workflow from triggering when your scheduled cleanup action updates issues via the API.

Option 1: Check the Actor/Triggering User

The simplest approach is to add a condition in your workflow to skip execution if the event was triggered by your cleanup bot/automation account.

Modify your workflow YAML to include an if condition on your job that excludes your bot username:

on:
  schedule:
    - cron: '10/15 * * * *'
  issues:
    types: [opened, closed, deleted, reopened, edited, labeled, unlabeled, assigned, unassigned]
  issue_comment:
    types: [created]

jobs:
  your_workflow_job:
    # Skip if the action was triggered by your cleanup bot
    if: github.actor != 'your-cleanup-bot-username'
    runs-on: ubuntu-latest
    steps:
      # Your existing workflow steps here

If you want more precision, you can check the sender of the event directly from the webhook payload:

if: github.event.sender.login != 'your-cleanup-bot-username'

Option 2: Add a Hidden Marker in Issue Updates

When your scheduled action uses Octokit to update issues, include a hidden HTML comment in the issue body or edit reason. Then, your workflow can check for this marker to skip execution.

For example, when updating an issue via Octokit, append this comment to the issue body:

// Example Octokit code to update an issue
await octokit.rest.issues.update({
  owner: 'your-org',
  repo: 'your-repo',
  issue_number: issueNumber,
  body: `${existingBody}\n<!-- bot-cleanup-operation -->`
});

Then update your workflow to skip if this marker exists:

jobs:
  your_workflow_job:
    if: !contains(github.event.issue.body, '<!-- bot-cleanup-operation -->')
    runs-on: ubuntu-latest
    steps:
      # Your existing workflow steps here

Option 3: Check for Automation Installation Context

If your cleanup action uses a GitHub App (instead of a personal access token), you can check if the event was triggered by the app’s installation. API calls from a GitHub App will include an installation object in the webhook payload, so you can use that to filter out automated events.

Add this condition to your job:

if: github.event.installation == null

This will skip the job whenever the event comes from your GitHub App-powered cleanup bot.

Summary

While there’s no native "skip ci" equivalent for issue events, these conditional checks let you effectively prevent your workflow from running when your automated cleanup action modifies issues. The actor check is usually the most straightforward and reliable method for most use cases.

内容的提问来源于stack exchange,提问作者a11smiles

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 17:57:30