Skip to content

fix(reviewer-bot): stop transition spam and repair freshness recovery #138

fix(reviewer-bot): stop transition spam and repair freshness recovery

fix(reviewer-bot): stop transition spam and repair freshness recovery #138

name: Reviewer Bot PR Metadata
on:
pull_request_target:
types: [opened, labeled, closed, synchronize]
permissions:
contents: read
env:
STATE_ISSUE_NUMBER: '314'
jobs:
reviewer-bot-pr-metadata:
runs-on: ubuntu-latest
permissions:
# Temporary lock debt: contents:write is allowed only for the existing lock-ref API operations.
contents: write
issues: write
pull-requests: write
actions: read
steps:
- name: Install uv
run: python -m pip install uv
- name: Fetch trusted bot source tarball
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python - <<'PY'
import io, os, tarfile, urllib.request
from pathlib import Path
req = urllib.request.Request(
f"https://api.github.com/repos/{os.environ['GITHUB_REPOSITORY']}/tarball/{os.environ['GITHUB_SHA']}",
headers={'Authorization': f"Bearer {os.environ['GITHUB_TOKEN']}", 'Accept': 'application/vnd.github+json'},
)
target = Path(os.environ['RUNNER_TEMP']) / 'reviewer-bot-src'
target.mkdir(parents=True, exist_ok=True)
with urllib.request.urlopen(req) as response:
data = response.read()
with tarfile.open(fileobj=io.BytesIO(data), mode='r:gz') as archive:
archive.extractall(target)
roots = list(target.iterdir())
print(f'BOT_SRC_ROOT={roots[0]}', file=open(os.environ['GITHUB_ENV'], 'a', encoding='utf-8'))
PY
- name: Run reviewer bot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT_NAME: pull_request_target
EVENT_ACTION: ${{ github.event.action }}
ISSUE_NUMBER: ${{ github.event.pull_request.number }}
ISSUE_AUTHOR: ${{ github.event.pull_request.user.login }}
ISSUE_LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
IS_PULL_REQUEST: 'true'
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
GITHUB_REPOSITORY: ${{ github.repository }}
WORKFLOW_RUN_ID: ${{ github.run_id }}
WORKFLOW_NAME: ${{ github.workflow }}
WORKFLOW_JOB_NAME: ${{ github.job }}
CURRENT_WORKFLOW_FILE: .github/workflows/reviewer-bot-pr-metadata.yml
run: uv run --project "$BOT_SRC_ROOT" reviewer-bot