github / safe-settings

ISC License
587 stars 140 forks source link

Invalid rules: 'Workflows' error when using the example yaml for organization ruleset #659

Open mikyjpeg opened 1 month ago

mikyjpeg commented 1 month ago

Problem Description

We're using the safe-setting to implement a ruleset at organisation level. The ruleset is created and works fine until we try to add a workflow rule. In such case, using a configuration that's pretty much identical to the one provided as example (https://github.com/github/safe-settings/blob/main-enterprise/docs/sample-settings/settings.yml#L343-L355) we receive an Invalid rules: 'Workflows' from the safe-setting execution

What is actually happening

This is the configuration part that trigger the issue:

rules:
      # # Choose which workflows must pass before branches can be merged.
      - type: workflows
        parameters:
          workflows:
            - path: .github/workflows/myworkflow.yml
              repository_id: 111111111 #actual id redacted
              ref: refs/heads/main

if the workflow type part is commented out the rules are applied correctly.

What is the expected behavior

The expected behavior is for the ruleset to be updated with the additional rule

Error output, if available

safe settings execution returns the following error

HttpError: Validation Failed: "Invalid rules: 'Workflows'"

The error seems to imply git hub api doesn't like the "workflow" object. However, the REST API docs seems to confirm the structure is correct as for https://docs.github.com/en/rest/orgs/rules?apiVersion=2022-11-28#create-an-organization-repository-rulesetfor

Context

Are you using the hosted instance of probot/settings or running your own?

We're running our own instance

If running your own instance, are you using it with github.com or GitHub Enterprise?

We are using GitHub enterprise but Cloud hosted on github.com

Version of probot/settings

safe settings 2.1.10

Version of GitHub Enterprise

the live one, we use cloud GHE

ron-nutrino commented 1 month ago

I'm experiencing the same issue