Skip to content

Commit ea5f065

Browse files
authored
[ci] Make maintainer check always remote (#32727)
To prevent local modification of the MAINTAINERS file we now always fetch from `main` instead.
1 parent 2d40460 commit ea5f065

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

.github/workflows/shared_check_maintainer.yml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ on:
66
actor:
77
required: true
88
type: string
9-
is_remote:
10-
required: false
11-
type: boolean
12-
default: false
139
outputs:
1410
is_core_team:
1511
value: ${{ jobs.check_maintainer.outputs.is_core_team }}
@@ -30,41 +26,27 @@ jobs:
3026
outputs:
3127
is_core_team: ${{ steps.check_if_actor_is_maintainer.outputs.result }}
3228
steps:
33-
- uses: actions/checkout@v4
3429
- name: Check if actor is maintainer
3530
id: check_if_actor_is_maintainer
3631
uses: actions/github-script@v7
3732
with:
3833
script: |
3934
const fs = require('fs');
4035
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');
4446
}
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');
6850
}
6951
7052
const maintainers = new Set(content.split('\n'));

0 commit comments

Comments
 (0)