Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2cb193415 | |||
| c475662e9f | |||
| 18c478ecf7 | |||
| 643e2f6b7f | |||
| c63220f924 | |||
| 556b0cc383 | |||
| 99eb9b9e6f | |||
| 00061934f6 | |||
| dcd1b25175 |
@@ -43,6 +43,20 @@ function extractOutputText(response) {
|
||||
return parts.join("\n").trim();
|
||||
}
|
||||
|
||||
function resolveGiteaApiUrl(event) {
|
||||
if (process.env.GITEA_API_URL) return process.env.GITEA_API_URL;
|
||||
|
||||
const repositoryApiUrl = event.repository?.url;
|
||||
const reposMarker = "/repos/";
|
||||
const markerIndex = repositoryApiUrl?.indexOf(reposMarker) ?? -1;
|
||||
if (markerIndex > 0) return repositoryApiUrl.slice(0, markerIndex);
|
||||
|
||||
const serverUrl = process.env.GITEA_SERVER_URL;
|
||||
if (serverUrl) return `${serverUrl.replace(/\/$/, "")}/api/v1`;
|
||||
|
||||
throw new Error("Cannot determine the Gitea API URL from the environment or event payload");
|
||||
}
|
||||
|
||||
async function upsertComment({ apiUrl, token, owner, repo, number, body }) {
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
@@ -98,7 +112,7 @@ async function main() {
|
||||
const diff = runGit(["diff", "--no-ext-diff", "--unified=30", `${baseSha}...${headSha}`]);
|
||||
const number = pull.number || event.number;
|
||||
const commentContext = {
|
||||
apiUrl: required("GITEA_API_URL"),
|
||||
apiUrl: resolveGiteaApiUrl(event),
|
||||
token: required("GITEA_TOKEN"),
|
||||
owner,
|
||||
repo,
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
if: ${{ gitea.event.pull_request.head.repo.full_name == gitea.repository }}
|
||||
steps:
|
||||
- name: Check out the trusted reviewer from the target revision
|
||||
uses: actions/checkout@v4
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ gitea.event.pull_request.base.sha }}
|
||||
fetch-depth: 0
|
||||
@@ -21,6 +21,7 @@ jobs:
|
||||
- name: Run AI review
|
||||
working-directory: trusted
|
||||
env:
|
||||
GITEA_API_URL: ${{ gitea.api_url }}
|
||||
GITEA_TOKEN: ${{ secrets.AI_REVIEW_GITEA_TOKEN }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
name: Actions Smoke Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: |
|
||||
echo "Gitea Actions is working"
|
||||
node --version
|
||||
Reference in New Issue
Block a user