1

Maybe this is out of the box, maybe not. But I can't find this in any of the documentation.

I know you can skip workflows on Push and Pull_Requests. However, I need to skip workflows when updating Issues via the REST API.

My current workflow yaml looks like the following:

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

The schedule job does some clean-up on issues via a custom action that leverages the GitHub/Octokit REST API.

Is there a way that I can prevent the workflow from running if the issue is updated via the API?

a11smiles
  • 1,190
  • 1
  • 9
  • 21
  • If I'm not mistaken, [you can only skip workflow runs triggered by the `push` and `pull_request` events](https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs). In your case (with ISSUE), you would need to add a check in a job or expression to identify if you should run or not the workflows operations. – GuiFalourd Aug 19 '22 at 15:29

1 Answers1

1

As @GuiFalourd points out in the comments, I think you will need to use Workflow Expressions. To differentiate between a GitHub API call or a user interaction call I'm not sure if there is an official way to do so, I would open an issue in GitHub Community. I'm sure they will help you with that.

A couple of workarounds coming to my mind is to use a special 'Issue label' to mark when the GitHub API is used, this way you can filter accordingly (not a fan of this solution).

Also, if you are using a certain GitHub user to do API requests, you can use github.actor and github.triggering_actor from GitHub context to identify which user is triggering the event.

Here's a draft on how my approach would look like:

steps:
  - uses: actions/hello-world-javascript-action@v1.1
    if: ${{ contains(fromJson('["push", "pull_request"]'), github.event_name) && github.actor == <your_actor_name> }}
OscarDOM
  • 716
  • 5
  • 15