File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : ' Check permissions'
2
+ description : ' Checks if commentor has write access or above'
3
+ runs :
4
+ using : ' node16'
5
+ main : ' index.js'
Original file line number Diff line number Diff line change
1
+ const core = require ( '@actions/core' ) ;
2
+ const github = require ( '@actions/github' ) ;
3
+
4
+ const octokit = new github . GitHub ( process . env . GITHUB_TOKEN ) ;
5
+ run ( ) ;
6
+ async function run ( ) {
7
+ const context = github . context ;
8
+ try {
9
+ // Get permission level of actor
10
+ const { data} = await octokit . repos . getCollaboratorPermissionLevel ( {
11
+ ...context . repo ,
12
+ username : context . actor
13
+ } ) ;
14
+
15
+ if ( ! [ 'admin' , 'write' ] . includes ( data . permission ) ) {
16
+ core . setFailed ( 'User doesn\'t have write permissions or higher' ) ;
17
+ }
18
+ } catch ( error ) {
19
+ core . setFailed ( error . message ) ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change 18
18
node-version : ' 16'
19
19
- name : install
20
20
run : yarn install
21
- - name : Comment contains trigger
21
+ - name : Check write permissions of commentor
22
+ uses : ./.github/actions/permissions
23
+ env :
24
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
25
+ - name : Create/update branch for fork PR
22
26
uses : ./.github/actions/branch
23
27
env :
24
28
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments