Automerge runs on skipped jobs

I am running a job when my pull request is labeled. But only for a certain label.

So, something like ths:

on:
  pull_request:
    branches:
      - master
    types:
      - labeled

jobs:
  my-job
  if: github.event.label.name == 'approved'

I want to automerge only if this job succeeds. So, I made it a required job for this branch.

But I also submit other labels to my pull request. that says the status is “Skipped”. But for the purposes of automerge, a skipped job is just as good as success. And so if I submit a different label, automerge would activate.

I did try check this method:

jobs:
  my-job
  steps:
      - name: Validate labels
        uses: docker://agilepathway/pull-request-label-checker:latest
        with:
          all_of: approved,deploy
          repo_token: ${{ secrets.GITHUB_TOKEN }}

But another wrinkle is that I am using this:

jobs:
  my-job:
    environment:
      name: prod

So, this would block on all sorts of labels until it is approved.

In my opinion, a skipped job is not the same as a successful job.

1 Like

We are running in the same issue.

Our setup is as follows:
We have a matrix job named “jobmatrix” and after that, there is a job “jobcombinator” that needs jobmatrix - e.g. it only executes if all matrix jobs succeed. Otherwise, it’s automatically skipped:
jobmatrix ----- -----> jobcombinator

When executing, it looks like the following:

job1 ----- \
job2 ----- -----> jobcombinator
job3 ----- /

So the matrix that spins up job1, 2, 3 and an execute and, once passed, jobcombinator will execute.

Now, jobcombinator is set as required check for PRs.

If a jobX fails, jobcombinator is skipped and we therefore cannot manually merge the PR (merge button is disabled). That’s how it is intended.

But if we set the PR to automerge, it will still be merged even if jobcombinator was skipped due to a failing jobX.

I think this is a bug that automerge merges PRs that have a required check skipped. I would expect it only merges if all required checks pass - as the “manual” method via clicking the merge button does.