diff --git a/.github/workflows/ai-run.yml b/.github/workflows/ai-run.yml index a639501..2f1b29c 100644 --- a/.github/workflows/ai-run.yml +++ b/.github/workflows/ai-run.yml @@ -85,7 +85,9 @@ jobs: - name: Run the agent runner env: GH_TOKEN: ${{ steps.mint.outputs.token }} - GITHUB_REPOSITORY: ${{ inputs.repo }} + # GITHUB_REPOSITORY is reserved and cannot be overridden by env:; + # the runner reads AI_TARGET_REPO first. + AI_TARGET_REPO: ${{ inputs.repo }} ISSUE_NUMBER: ${{ inputs.issue }} WORK_DIR: ${{ env.WORK_DIR }} DEFAULT_BRANCH: ${{ env.DEFAULT_BRANCH }} @@ -117,7 +119,7 @@ jobs: if: always() uses: actions/upload-artifact@v7 with: - name: ai-run-${{ inputs.repo }}-${{ inputs.issue }} + name: ai-run-${{ inputs.issue }}-${{ github.run_id }} path: ${{ runner.temp }}/ai-issue-${{ inputs.issue }} if-no-files-found: ignore retention-days: 7 diff --git a/agent-runner/src/main.ts b/agent-runner/src/main.ts index 5ade8c4..c938c92 100644 --- a/agent-runner/src/main.ts +++ b/agent-runner/src/main.ts @@ -166,7 +166,9 @@ function riskLine(risk: RiskAssessment | null): string { } async function main(): Promise { - const repo = requireEnv("GITHUB_REPOSITORY"); + // `AI_TARGET_REPO` is for workflows that cannot override the reserved + // GITHUB_REPOSITORY variable (ai-run.yml runs one task for a foreign repo). + const repo = process.env.AI_TARGET_REPO?.trim() || requireEnv("GITHUB_REPOSITORY"); const issueNumber = Number(requireEnv("ISSUE_NUMBER")); if (!Number.isInteger(issueNumber) || issueNumber <= 0) throw new Error(`Bad ISSUE_NUMBER: ${process.env.ISSUE_NUMBER}`);