'How to set a whole GitHub Actions workflow as a required status check on a protected branch (instead of individual jobs)?

The search bar for setting required status checks suggest only the names of individual jobs in workflows. They don't suggest the whole workflow.

This is inconvenient, because if I add a new job to the workflow, I would need to add this new job to the list of required status checks for the branch.

Is there a way of setting a whole GitHub Actions workflow as a required status check on a protected branch?

GitHub protected branch status checks UI



Solution 1:[1]

you could use workflow_run to trigger your workflow like this:

on:
  push:
    branches:
      - main
  workflow_run:
    workflows: ["workflow1", "workflow2"]
    types:
      - completed
    branches:
      - main

More details in the docs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vsr