Skip to content

Commit a1af728

Browse files
zaniebzaniebot
andauthored
Authorize report publishing and reviewer selection (astral-sh#29617)
Authorize report publishing and reviewer selection through `.github/key-value-store.json` and `.github/secure-token-service.json`, which the services read from `main`. The four report workflows receive KV `read` and `write` access in `pull-request` scope and STS `actions: read` and `pull_requests: write` permissions for `pull_request` runs through the publisher on `main`. `pull-request-reviewers.yml` receives KV `read` and `write` access in `workflow` scope and STS `pull_requests: write` permission for `workflow_dispatch` runs on `main`. All of these new grants require the `automations` environment; none allow KV `delete`. --------- Co-authored-by: zaniebot <242828183+zaniebot@users.noreply.github.com>
1 parent 7a8f63f commit a1af728

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

‎.github/key-value-store.json‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"version": 1,
3+
"rules": [
4+
{
5+
"on": ["workflow_dispatch"],
6+
"caller_workflow": "pull-request-reviewers.yml",
7+
"caller_ref": "refs/heads/main",
8+
"environment": "automations",
9+
"reusable_workflow": "astral-sh/ruff/.github/workflows/pull-request-reviewers.yml@refs/heads/main",
10+
"permissions": { "workflow": ["read", "write"] }
11+
},
12+
{
13+
"on": ["pull_request"],
14+
"caller_workflow": "ci.yaml",
15+
"caller_ref": "refs/pull/*/merge",
16+
"environment": "automations",
17+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
18+
"permissions": { "pull-request": ["read", "write"] }
19+
},
20+
{
21+
"on": ["pull_request"],
22+
"caller_workflow": "memory_report.yaml",
23+
"caller_ref": "refs/pull/*/merge",
24+
"environment": "automations",
25+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
26+
"permissions": { "pull-request": ["read", "write"] }
27+
},
28+
{
29+
"on": ["pull_request"],
30+
"caller_workflow": "typing_conformance.yaml",
31+
"caller_ref": "refs/pull/*/merge",
32+
"environment": "automations",
33+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
34+
"permissions": { "pull-request": ["read", "write"] }
35+
},
36+
{
37+
"on": ["pull_request"],
38+
"caller_workflow": "ty-ecosystem-analyzer.yaml",
39+
"caller_ref": "refs/pull/*/merge",
40+
"environment": "automations",
41+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
42+
"permissions": { "pull-request": ["read", "write"] }
43+
}
44+
]
45+
}

‎.github/secure-token-service.json‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,55 @@
1414
}
1515
},
1616
"rules": [
17+
{
18+
"caller": "ruff",
19+
"environment": "automations",
20+
"caller_ref": "refs/heads/main",
21+
"caller_workflow": "pull-request-reviewers.yml",
22+
"on": ["workflow_dispatch"],
23+
"permissions": { "pull_requests": "write" },
24+
"target": "ruff"
25+
},
26+
{
27+
"caller": "ruff",
28+
"environment": "automations",
29+
"caller_ref": "refs/pull/*/merge",
30+
"caller_workflow": "ty-ecosystem-analyzer.yaml",
31+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
32+
"on": ["pull_request"],
33+
"permissions": { "actions": "read", "pull_requests": "write" },
34+
"target": "ruff"
35+
},
36+
{
37+
"caller": "ruff",
38+
"environment": "automations",
39+
"caller_ref": "refs/pull/*/merge",
40+
"caller_workflow": "typing_conformance.yaml",
41+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
42+
"on": ["pull_request"],
43+
"permissions": { "actions": "read", "pull_requests": "write" },
44+
"target": "ruff"
45+
},
46+
{
47+
"caller": "ruff",
48+
"environment": "automations",
49+
"caller_ref": "refs/pull/*/merge",
50+
"caller_workflow": "memory_report.yaml",
51+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
52+
"on": ["pull_request"],
53+
"permissions": { "actions": "read", "pull_requests": "write" },
54+
"target": "ruff"
55+
},
56+
{
57+
"caller": "ruff",
58+
"environment": "automations",
59+
"caller_ref": "refs/pull/*/merge",
60+
"caller_workflow": "ci.yaml",
61+
"reusable_workflow": "astral-sh/ruff/.github/workflows/publish-pull-request-report.yml@refs/heads/main",
62+
"on": ["pull_request"],
63+
"permissions": { "actions": "read", "pull_requests": "write" },
64+
"target": "ruff"
65+
},
1766
{
1867
"caller": "ruff",
1968
"environment": "automations",

0 commit comments

Comments
 (0)