|
7 | 7 | days. This treats anything other than success/skipped as a problem. |
8 | 8 |
|
9 | 9 | One exception: GitHub's dynamic "Dependabot Updates" workflow cannot be |
10 | | -disabled, and its old runs outlive the `.github/dependabot.yml` that started |
11 | | -them. Without that file no version update can run, so in a repository that |
12 | | -has none the workflow is skipped as a leftover. |
| 10 | +disabled, and its old runs outlive the `.github/dependabot.yml` (or `.yaml`) |
| 11 | +that started them. Without that file no version update can run, so in a |
| 12 | +repository that has neither the workflow is skipped as a leftover. |
13 | 13 |
|
14 | 14 | It only reads. The report goes to stdout and the run's step summary; nothing |
15 | 15 | is written to GitHub and nobody is mentioned, so it runs only when a person |
|
46 | 46 |
|
47 | 47 | # GitHub's own workflow for Dependabot, present even after its config is gone. |
48 | 48 | DEPENDABOT_WORKFLOW = "dynamic/dependabot/" |
| 49 | +DEPENDABOT_CONFIGS = ("dependabot.yml", "dependabot.yaml") |
49 | 50 |
|
50 | 51 |
|
51 | 52 | @dataclass |
@@ -131,18 +132,23 @@ def workflow_token_findings(repo: str, branch: str, workflow: dict[str, Any], |
131 | 132 |
|
132 | 133 |
|
133 | 134 | def dependabot_configured(repo: str, token: str | None) -> bool: |
134 | | - """Whether the repository has `.github/dependabot.yml` on its default branch. |
| 135 | + """Whether the repository has `.github/dependabot.yml` or `.yaml` on its default branch. |
135 | 136 |
|
136 | | - A 404 means it has none. Any other failure counts as configured, so a |
137 | | - lookup that went wrong never hides a real Dependabot failure. |
| 137 | + GitHub accepts either name, so `.yaml` is tried only when `.yml` is a 404, |
| 138 | + and only two 404s mean there is none. Any other failure counts as |
| 139 | + configured, so a lookup that went wrong never hides a real Dependabot failure. |
138 | 140 | """ |
139 | | - try: |
140 | | - _get(f"{API}/repos/{repo}/contents/.github/dependabot.yml", token) |
141 | | - except urllib.error.HTTPError as exc: |
142 | | - return exc.code != 404 |
143 | | - except urllib.error.URLError: |
| 141 | + for name in DEPENDABOT_CONFIGS: |
| 142 | + try: |
| 143 | + _get(f"{API}/repos/{repo}/contents/.github/{name}", token) |
| 144 | + except urllib.error.HTTPError as exc: |
| 145 | + if exc.code == 404: |
| 146 | + continue |
| 147 | + return True |
| 148 | + except urllib.error.URLError: |
| 149 | + return True |
144 | 150 | return True |
145 | | - return True |
| 151 | + return False |
146 | 152 |
|
147 | 153 |
|
148 | 154 | def leftover_workflow(workflow: dict[str, Any], has_dependabot_config: bool) -> bool: |
|
0 commit comments