githubgithub-actions

Where to locate workflow definition for GitHub ruleset required workflows?


I'm trying to create a required workflow, i.e. a workflow declared in a host repo that can be run against other repos via an org level ruleset.

Originally I was working off of this doc that stated:

Required workflows can be stored in any repository folder and are not restricted to the .github/workflows folder like normal workflows.

However, when I tried to place my workflows in a subfolder it prevented me from creating a ruleset using the workflow:

enter image description here

I relocated my workflow to the .github/workflows directory and was able to create the ruleset. However, my workflow is now running against the repository hosting it like any other workflow would. This workflow is not meant to execute against the host, only repositories targeted by the ruleset.

Where do I define my workflow such that I can use it in a ruleset as a required workflow and it will not be executed against the host repository?


Solution

  • The ruleset does have to go in the ./github/workflows directory.

    To get around the issue of the workflow running in the host repository (without adding conditions to all the jobs which results in skipped checks in the Pull Request):

    In the required workflow host repo:

    1. Navigate to the Actions tab
    2. Select the workflow
    3. Click the ellipsis
    4. Select Disable workflow

    menu options