This repository has been archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const axios = require('axios'); | ||
const fs = require('fs'); | ||
|
||
const PR_NUMBER = process.env.GITHUB_EVENT_PATH ? JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')).number : null; | ||
const REPO = process.env.GITHUB_REPOSITORY; | ||
const TOKEN = process.env.GITHUB_TOKEN; | ||
|
||
console.log(`https://api.github.com/repos/${REPO}/pulls/${PR_NUMBER}/files`); | ||
|
||
axios.get(`https://api.github.com/repos/${REPO}/pulls/${PR_NUMBER}/files`, {}) | ||
.then(response => { | ||
const files = response.data; | ||
const root_directories = new Set(); | ||
|
||
files.forEach(file => { | ||
const root_directory = file.filename.split("/")[0]; | ||
root_directories.add(root_directory); | ||
}); | ||
|
||
if (root_directories.size > 1) { | ||
throw new Error("Multiple root directories changed, action failed."); | ||
} | ||
|
||
const root_dir = [...root_directories][0]; | ||
console.log(`::set-output name=root_directory::${root_dir}`); | ||
}) | ||
.catch(error => { | ||
console.error(error.message || 'Error occurred'); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# backend_2023_freshman_task | ||
|
||
2023 杭助后端招新小任务提交仓库 | ||
|
||
- fork本仓库 | ||
- git clone 你 fork 出来的仓库 | ||
- 在仓库根目录下新建一个和你 github 用户名同名的文件夹 | ||
- 在此文件夹内,放入你的代码 | ||
- 提交 Pull request | ||
- github action通过后,即为提交成功 |