返回提交历史
Modified
.github/workflows/copilot.yml
+26
-4
Modified
.github/workflows/unittest.yml
+11
-1
Modified
etc/tool/copilot.py
+6
-4
XFEstudio/gpt4free
Save pr number
f7201059
代码差异
3 个文件
+43
-9
@@ -13,19 +13,41 @@ jobs:
13
13
contents: read
14
14
pull-requests: write
15
15
steps:
16
- name: 'Download artifact'
17
uses: actions/github-script@v6
18
with:
19
script: |
20
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
21
owner: context.repo.owner,
22
repo: context.repo.repo,
23
run_id: context.payload.workflow_run.id,
24
});
25
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
26
return artifact.name == "pr_number"
27
})[0];
28
let download = await github.rest.actions.downloadArtifact({
29
owner: context.repo.owner,
30
repo: context.repo.repo,
31
artifact_id: matchArtifact.id,
32
archive_format: 'zip',
33
});
34
let fs = require('fs');
35
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
36
- name: 'Unzip artifact'
37
run: unzip pr_number.zip
16
38
- name: Checkout Repo
17
39
uses: actions/checkout@v3
18
19
40
- name: Setup Python
20
41
uses: actions/setup-python@v4
21
42
with:
22
43
python-version: "3.x"
23
44
cache: 'pip'
24
45
- name: Install Requirements
25
run: pip install -r requirements.txt
26
- name: Install PyGithub
27
run: pip install PyGithub
46
run: |
47
pip install -r requirements.txt
48
pip install PyGithub
28
49
- name: AI Code Review
29
50
env:
30
51
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52
GITHUB_REPOSITORY: ${{ github.repository }}
31
53
run: python -m etc.tool.copilot
@@ -23,4 +23,14 @@ jobs:
23
23
- name: Install requirements
24
24
run: pip install -r requirements.txt
25
25
- name: Run tests
26
run: python -m etc.unittest
26
run: python -m etc.unittest
27
- name: Save PR number
28
env:
29
PR_NUMBER: ${{ github.event.number }}
30
run: |
31
mkdir -p ./pr
32
echo $PR_NUMBER > ./pr/pr_number
33
- uses: actions/upload-artifact@v4
34
with:
35
name: pr_number
36
path: pr/
@@ -16,6 +16,7 @@ g4f.debug.logging = True
16
16
g4f.debug.version_check = False
17
17
18
18
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
19
GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY')
19
20
G4F_PROVIDER = os.getenv('G4F_PROVIDER')
20
21
G4F_MODEL = os.getenv('G4F_MODEL') or g4f.models.gpt_4
21
22
@@ -29,11 +30,12 @@ def get_pr_details(github: Github) -> PullRequest:
29
30
Returns:
30
31
PullRequest: An object representing the pull request.
31
32
"""
32
with open(os.getenv('GITHUB_EVENT_PATH', ''), 'r') as file:
33
data = json.load(file)
33
'./pr_number'
34
with open('./pr_number', 'r') as file:
35
pr_number = file.read()
34
36
35
repo = github.get_repo(f"{data['repository']['owner']['login']}/{data['repository']['name']}")
36
pull = repo.get_pull(data['number'])
37
repo = github.get_repo(GITHUB_REPOSITORY)
38
pull = repo.get_pull(pr_number)
37
39
38
40
return pull
39
41