6
6
actor :
7
7
required : true
8
8
type : string
9
- is_remote :
10
- required : false
11
- type : boolean
12
- default : false
13
9
outputs :
14
10
is_core_team :
15
11
value : ${{ jobs.check_maintainer.outputs.is_core_team }}
@@ -30,41 +26,27 @@ jobs:
30
26
outputs :
31
27
is_core_team : ${{ steps.check_if_actor_is_maintainer.outputs.result }}
32
28
steps :
33
- - uses : actions/checkout@v4
34
29
- name : Check if actor is maintainer
35
30
id : check_if_actor_is_maintainer
36
31
uses : actions/github-script@v7
37
32
with :
38
33
script : |
39
34
const fs = require('fs');
40
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');
44
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');
68
50
}
69
51
70
52
const maintainers = new Set(content.split('\n'));
0 commit comments