Files
Liti-agent-Development/.gitea/workflows/run-agent.yml
T
jsahnandClaude Opus 4.8 1f34c9186f fix: downgrade upload-artifact to v3 for Gitea compatibility
Gitea Actions only supports the v3 artifact protocol; upload-artifact@v4
uses the @actions/artifact v2 API which Gitea (identifying as GHES) rejects
with GHESNotSupportedError. The agent run step itself succeeds; only the
artifact upload was failing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 15:50:01 +09:00

123 lines
5.2 KiB
YAML

# 지정한 Agent YAML 을 AgentBackend API 로 실행하는 Gitea Actions 워크플로우.
#
# 사용법: Gitea 저장소 → Actions 탭 → "Run Agent YAML via API" → Run workflow
# yaml_path 에 repo 상대경로 입력, 예:
# Case_02_Comparison_Research/YAML_Prompts/1. Stage_1/v.5/Stage_1_Part_4.yml
#
# 요구사항:
# - 저장소 설정에서 Actions 활성화 + act_runner 등록 (runs-on: ubuntu-latest 라벨)
# - 러너가 백엔드에 내부 주소로 접근 가능해야 함 (아래 api_base 참고)
#
# 인증 (중요):
# 공개 URL(https://legalpoc.eroomai.com)은 Google OAuth 프록시(auth.eroomai.com)
# 뒤에 있어서 CI 에서는 302 로 로그인 페이지로 튕긴다. localhost:8800 도 job 이
# 컨테이너 안에서 돌면 컨테이너 자신을 가리켜 못 닿는다.
# → 해결: act_runner 의 job 컨테이너를 AgentBackend 와 같은 도커 네트워크에 붙이고
# 내부 컨테이너 주소로 직접 호출한다(프록시 우회). 내부 백엔드는 /api 접두사 없이
# 루트로 API 를 제공한다(/upload-agent, /sse/agent/...).
# 러너 설정 (서버, /opt/gitea-runner-scale/):
# config.yaml 의 container.network 를 백엔드 네트워크 이름으로 지정
# (docker network ls 로 확인, 보통 agentbackend_agent-network).
# 그러면 api_base = http://agent-backend:8000 (container_name, 내부 포트 8000).
#
# 실행 흐름 (SKILL.md §0.6 경로 A):
# upload-agent 등록 → SSE start → stage_complete 자동 confirm → execution_complete
# stage_error 발생 시 세션을 cancel 하고 실패 처리한다.
# 전체 이벤트 로그 / final_output / summary 는 아티팩트로 저장된다.
#
# 실행 시간 상한 (주의):
# Gitea 의 [actions] ENDLESS_TASK_TIMEOUT 과 act_runner 의 runner.timeout 기본값이
# 각각 3h 라서, timeout-minutes 를 아무리 크게 줘도 3h 에서 강제 종료된다.
# 강제 종료되면 if: always() 아티팩트 업로드도 건너뛰므로,
# 스크립트의 --max-runtime(기본 9000s=150m) 이 먼저 세션을 정리하고 종료하도록
# max_runtime < timeout-minutes(175m) < 3h 순서를 유지한다.
# 3h 이상 돌려야 하면: app.ini 의 ENDLESS_TASK_TIMEOUT, act_runner config 의
# runner.timeout, 아래 timeout-minutes, max_runtime 입력을 모두 함께 올릴 것.
name: Run Agent YAML via API
on:
workflow_dispatch:
inputs:
yaml_path:
description: '실행할 Agent YAML 경로 (repo 상대경로)'
required: true
type: string
user_id:
description: 'AgentBackend user_id'
required: false
default: 'jsahn'
type: string
workspace_id:
description: 'AgentBackend workspace_id'
required: false
default: 'e1d0baed-cec9-44af-9989-b7aab09bcfd1'
type: string
user_input:
description: 'Agent 에 전달할 user_input'
required: false
default: ''
type: string
start_stage_index:
description: '시작 stage 인덱스 (0-based)'
required: false
default: '0'
type: string
api_base:
description: 'AgentBackend API base URL (내부 컨테이너 주소, /api 접두사 없음)'
required: false
default: 'http://agent-backend:8000'
type: string
max_runtime_seconds:
description: '총 실행 시간 상한(초). Gitea/act_runner 3h 상한보다 짧게'
required: false
default: '9000'
type: string
jobs:
run-agent:
runs-on: ubuntu-latest
timeout-minutes: 175
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: python -m pip install --quiet httpx httpx-sse
- name: Run agent via API
env:
YAML_PATH: ${{ inputs.yaml_path }}
API_BASE: ${{ inputs.api_base }}
AGENT_USER_ID: ${{ inputs.user_id }}
AGENT_WORKSPACE_ID: ${{ inputs.workspace_id }}
AGENT_USER_INPUT: ${{ inputs.user_input }}
START_STAGE_INDEX: ${{ inputs.start_stage_index }}
MAX_RUNTIME_SECONDS: ${{ inputs.max_runtime_seconds }}
# '=' 형식 필수: user_input 이 '-' 로 시작하는 자유 텍스트여도 argparse 가 값으로 인식
run: |
python scripts/run_agent_api.py \
--yaml-path="$YAML_PATH" \
--api-base="$API_BASE" \
--user-id="$AGENT_USER_ID" \
--workspace-id="$AGENT_WORKSPACE_ID" \
--user-input="$AGENT_USER_INPUT" \
--start-stage-index="$START_STAGE_INDEX" \
--max-runtime="$MAX_RUNTIME_SECONDS" \
--output-dir=agent_run_output
# Gitea Actions 는 아티팩트 v3 프로토콜만 지원한다. upload-artifact@v4 는
# @actions/artifact v2 API 를 써서 Gitea(GHES 로 식별됨)에서 거부되므로 v3 사용.
- name: Upload run artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: agent-run-${{ github.run_number }}
path: agent_run_output/
if-no-files-found: warn