This repository was archived by the owner on Oct 17, 2023. It is now read-only.
File tree 4 files changed +66
-0
lines changed
4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ const axios = require ( 'axios' ) ;
2
+ const fs = require ( 'fs' ) ;
3
+
4
+ const PR_NUMBER = process . env . GITHUB_EVENT_PATH ? JSON . parse ( fs . readFileSync ( process . env . GITHUB_EVENT_PATH , 'utf8' ) ) . number : null ;
5
+ const REPO = process . env . GITHUB_REPOSITORY ;
6
+
7
+ console . log ( `https://api.github.com/repos/${ REPO } /pulls/${ PR_NUMBER } /files` ) ;
8
+
9
+ axios . get ( `https://api.github.com/repos/${ REPO } /pulls/${ PR_NUMBER } /files` , { } )
10
+ . then ( response => {
11
+ const files = response . data ;
12
+ const root_directories = new Set ( ) ;
13
+
14
+ files . forEach ( file => {
15
+ const root_directory = file . filename . split ( "/" ) [ 0 ] ;
16
+ root_directories . add ( root_directory ) ;
17
+ } ) ;
18
+
19
+ if ( root_directories . size > 1 ) {
20
+ throw new Error ( "Multiple root directories changed, action failed." ) ;
21
+ }
22
+
23
+ const root_dir = [ ...root_directories ] [ 0 ] ;
24
+ console . log ( `::set-output name=root_directory::${ root_dir } ` ) ;
25
+ } )
26
+ . catch ( error => {
27
+ console . error ( error . message || 'Error occurred' ) ;
28
+ process . exit ( 1 ) ;
29
+ } ) ;
Original file line number Diff line number Diff line change
1
+ name : Check PR Requirements
2
+
3
+ on :
4
+ pull_request :
5
+
6
+ jobs :
7
+ check-pr :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - name : Checkout code
11
+ uses : actions/checkout@v4
12
+
13
+ - name : Install Node.js
14
+ uses : actions/setup-node@v2
15
+ with :
16
+ node-version : ' 14'
17
+
18
+ - name : Install dependencies
19
+ run : |
20
+ npm install axios
21
+
22
+ - name : Get root directory
23
+ run : node .github/scripts/get_root_directories.js
24
+ id : get-dir
Original file line number Diff line number Diff line change
1
+ .idea
2
+
3
+ ** /node_modules /
Original file line number Diff line number Diff line change
1
+ # frontend_2023_freshman_task
2
+
3
+ 2023 杭助前端招新小任务提交仓库
4
+
5
+ - fork本仓库
6
+ - git clone 你 fork 出来的仓库
7
+ - 在仓库根目录下新建一个和你 github 用户名同名的文件夹
8
+ - 在此文件夹内,放入你的代码
9
+ - 提交 Pull request
10
+ - github action通过后,即为提交成功
You can’t perform that action at this time.
0 commit comments