[ci] Make maintainer check always remote (#32727)
To prevent local modification of the MAINTAINERS file we now always fetch from `main` instead.
lauren committed
Mar 24, 2025 at 16:40 UTC
ea5f065745b777cb41cc9e54a3b29ed8c727a574
1 file changed
+13
-31
.github/workflows/shared_check_maintainer.yml
+13
-31
@@ -6,10 +6,6 @@ on:
6
actor:
7
required: true
8
type: string
9
- is_remote:
10
- required: false
11
- type: boolean
12
- default: false
9
outputs:
10
is_core_team:
11
value: ${{ jobs.check_maintainer.outputs.is_core_team }}
@@ -30,7 +26,6 @@ jobs:
26
outputs:
27
is_core_team: ${{ steps.check_if_actor_is_maintainer.outputs.result }}
28
steps:
33
- - uses: actions/checkout@v4
29
- name: Check if actor is maintainer
30
id: check_if_actor_is_maintainer
31
uses: actions/github-script@v7
@@ -38,33 +33,20 @@ jobs:
33
script: |
34
const fs = require('fs');
35
const actor = '${{ inputs.actor }}';
41
- let isRemote = ${{ inputs.is_remote }};
42
- if (typeof isRemote === 'string') {
43
- isRemote = isRemote === 'true';
36
+ const res = await github.rest.repos.getContent({
37
+ owner: 'facebook',
38
+ repo: 'react',
39
+ path: 'MAINTAINERS',
40
+ ref: 'main',
41
+ headers: { Accept: 'application/vnd.github+json' }
42
+ });
43
+ if (res.status !== 200) {
44
+ console.error(res);
45
+ throw new Error('Unable to fetch MAINTAINERS file');
46
}
45
- if (typeof isRemote !== 'boolean') {
46
- throw new Error(`Invalid \`isRemote\` input. Expected a boolean, got: ${isRemote}`);
47
- }
48
-
49
- let content = null;
50
- if (isRemote === true) {
51
- const res = await github.rest.repos.getContent({
52
- owner: 'facebook',
53
- repo: 'react',
54
- path: 'MAINTAINERS',
55
- ref: 'main',
56
- headers: { Accept: 'application/vnd.github+json' }
57
- });
58
- if (res.status !== 200) {
59
- console.error(res);
60
- throw new Error('Unable to fetch MAINTAINERS file');
61
- }
62
- content = Buffer.from(res.data.content, 'base64').toString();
63
- } else {
64
- content = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' });
65
- }
66
- if (content === null) {
67
- throw new Error('Unable to retrieve local or http MAINTAINERS file');
47
+ content = Buffer.from(res.data.content, 'base64').toString();
48
+ if (content == null || typeof content !== 'string') {
49
+ throw new Error('Unable to retrieve MAINTAINERS file');
50
}
51
52
const maintainers = new Set(content.split('\n'));