diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 2436862..a65aa6a 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -6,7 +6,7 @@ name: "Reusable Dependabot Auto-merge Workflow" # # Why not a bare `gh pr merge --auto`: native auto-merge only waits on the # checks that branch protection marks *required*, and merges immediately if -# none are required (or if the required set is stale / mis-named). That lets a +# none are required (or if the required set is stale / misnamed). That lets a # red or still-running PR fast-track when a repo's required-status-checks config # is missing or out of date. This workflow instead gates on ALL checks that # actually ran on the head commit, so the gate holds regardless of branch @@ -14,10 +14,8 @@ name: "Reusable Dependabot Auto-merge Workflow" # times out, the PR is left for a human with an explanatory comment (the job # still succeeds — holding is a valid outcome). # -# The caller triggers on pull_request and must grant contents + pull-requests -# write. `checks: read` + `statuses: read` are used to inspect CI; reads work -# without an explicit grant on public repos, but private repos should also -# grant those two scopes on the caller job. +# The pull_request caller must grant contents and pull-requests write access +# plus checks and statuses read access in both public and private repositories. on: workflow_call: diff --git a/Monorepo.md b/Monorepo.md index 0b05907..c398a78 100644 --- a/Monorepo.md +++ b/Monorepo.md @@ -503,8 +503,12 @@ group from `test_groups.toml` and schedules it on the GPU runner. Every workflow in `.github/workflows/` is a **thin caller** that delegates to a reusable workflow in `SciML/.github` at `@v1`, with `secrets: "inherit"`. Do not inline build/test steps, permissions, or matrices that a reusable workflow -already owns. The target set (the whole fleet, including OrdinaryDiffEq, is being -converted to these thin-caller forms): +already owns. The exception is `permissions:` — a reusable job cannot elevate +its caller's token, and an explicitly enumerated map downgrades every omitted +scope to `none`, so a caller that writes a map must still list every scope the +reusable job requests (see the TagBot and DependabotAutoMerge callers below). +The target set (the whole fleet, including OrdinaryDiffEq, is being converted +to these thin-caller forms): ### `SublibraryCI.yml` → `sublibrary-project-tests.yml@v1` @@ -687,7 +691,19 @@ is unnecessary when there is only one package to scan. See the ### `DependabotAutoMerge.yml` → `dependabot-automerge.yml@v1` +Keep the caller permissions shown below — the same elevation rule as TagBot +applies, and omitting `checks: read` or `statuses: read` rejects the workflow +before any job is created. + ```yaml +# .github/workflows/DependabotAutoMerge.yml +name: Dependabot Auto-merge +on: pull_request +permissions: + contents: write + pull-requests: write + checks: read + statuses: read jobs: automerge: uses: "SciML/.github/.github/workflows/dependabot-automerge.yml@v1" diff --git a/README.md b/README.md index 8bace7b..251dcd8 100644 --- a/README.md +++ b/README.md @@ -467,6 +467,13 @@ out, the PR is left for a human with an explanatory comment (the job still succeeds — holding is a valid outcome, not a failure). No repo-level "auto-merge enabled" setting is required. +In both public and private repositories, grant the calling job all four +permissions shown below. GitHub validates the reusable job's permissions before +evaluating its Dependabot actor condition. Omitting either `checks: read` or +`statuses: read` from an explicit permissions map causes a startup failure on +every pull request; a caller with no `permissions:` map inherits the +repository's default token scopes instead. + | Input | Type | Default | Description | |---|---|---|---| | `update-types` | string | `"version-update:semver-patch,version-update:semver-minor"` | Dependabot update types to auto-merge. | @@ -481,8 +488,8 @@ on: pull_request permissions: contents: write pull-requests: write - checks: read # only needed on private repos - statuses: read # only needed on private repos + checks: read + statuses: read jobs: automerge: uses: "SciML/.github/.github/workflows/dependabot-automerge.yml@v1"