Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/opencode-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,7 @@ jobs:
local review_payload_file
gh_error_file="$(mktemp)"
review_payload_file="$(mktemp)"
emit_review_body_to_action_log "$event" "$body"
jq -n \
--arg event "$event" \
--arg body "$body" \
Expand All @@ -2150,6 +2151,61 @@ jobs:
update_review_overview "$event" "$body"
}

emit_review_body_to_action_log() {
local event="$1" body="$2" review_payload_file="${3:-}"
local stop_token

case "$event" in
REQUEST_CHANGES | INLINE_COMMENT_PUBLISH_FAILED) ;;
*) return 0 ;;
esac

stop_token="opencode-review-body-${RUN_ID}-${RUN_ATTEMPT}-${RANDOM}"
printf '::group::OpenCode %s review body\n' "$event"
printf '::stop-commands::%s\n' "$stop_token"
printf 'OpenCode is publishing this review content to PR #%s.\n\n' "$PR_NUMBER"
printf -- '- Event: %s\n' "$event"
printf -- '- Head SHA: %s\n' "$HEAD_SHA"
printf -- '- Workflow run: %s\n' "$RUN_ID"
printf -- '- Workflow attempt: %s\n\n' "$RUN_ATTEMPT"
printf '%s\n' "$body"
if [ -s "$review_payload_file" ]; then
printf '\n## Inline review comments\n\n'
jq -r '
(.comments // [])
| to_entries[]
| "### Inline comment " + ((.key + 1) | tostring)
+ " on `" + (.value.path // "unknown") + ":" + ((.value.line // 0) | tostring) + "`\n\n"
+ (.value.body // "")
+ "\n"
' "$review_payload_file" || true
fi
printf '::%s::\n' "$stop_token"
printf '::endgroup::\n'

if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
{
printf '## OpenCode %s review body\n\n' "$event"
printf -- '- Head SHA: `%s`\n' "$HEAD_SHA"
printf -- '- Workflow run: %s\n' "$RUN_ID"
printf -- '- Workflow attempt: %s\n\n' "$RUN_ATTEMPT"
printf '%s\n' "$body"
if [ -s "$review_payload_file" ]; then
printf '\n## Inline review comments\n\n'
jq -r '
(.comments // [])
| to_entries[]
| "### Inline comment " + ((.key + 1) | tostring)
+ " on `" + (.value.path // "unknown") + ":" + ((.value.line // 0) | tostring) + "`\n\n"
+ (.value.body // "")
+ "\n"
' "$review_payload_file" || true
fi
printf '\n'
} >>"$GITHUB_STEP_SUMMARY"
fi
}

stop_approval_without_review() {
local result="$1"
local body="$2"
Expand Down Expand Up @@ -2348,6 +2404,7 @@ jobs:
local event="$1" body="$2" review_payload_file="$3" fallback_body_file="$4"
local gh_error_file
gh_error_file="$(mktemp)"
emit_review_body_to_action_log "$event" "$body" "$review_payload_file"
if ! gh api -X POST "repos/${GH_REPOSITORY}/pulls/${PR_NUMBER}/reviews" --input "$review_payload_file" >/dev/null 2>"$gh_error_file"; then
warn_gh_publication_failure "pull review inline comments" "$gh_error_file"
rm -f "$gh_error_file"
Expand Down
66 changes: 58 additions & 8 deletions .github/workflows/pr-review-merge-scheduler.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
name: PR Review Merge Scheduler

on:
workflow_call:
inputs:
dry_run:
description: Print planned actions without mutating PRs
required: false
default: false
type: boolean
max_prs:
description: Maximum open PRs to inspect
required: false
default: "100"
type: string
trigger_reviews:
description: Dispatch OpenCode Review for PR heads without current approval
required: false
default: true
type: boolean
enable_auto_merge:
description: Enable auto-merge for current-head approved PRs
required: false
default: true
type: boolean
update_branches:
description: Update outdated PR branches after OpenCode approval
required: false
default: true
type: boolean
stale_opencode_minutes:
description: Redispatch OpenCode Review when an in-progress OpenCode check is older than this many minutes
required: false
default: "45"
type: string
project_flow:
description: Project flow, usually github-flow or git-flow
required: false
default: ""
type: string
base_branch:
description: Base branch to scan; defaults to the caller repository default branch
required: false
default: ""
type: string
canonical_ref:
description: Ref of ContextualWisdomLab/.github to use for scheduler code
required: false
default: "main"
type: string
schedule:
- cron: "17 */2 * * *"
workflow_dispatch:
Expand Down Expand Up @@ -35,7 +82,7 @@ on:
default: "45"

concurrency:
group: pr-review-merge-scheduler
group: pr-review-merge-scheduler-${{ github.repository }}
cancel-in-progress: false

jobs:
Expand All @@ -48,19 +95,22 @@ jobs:
pull-requests: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == true }}
GH_TOKEN: ${{ github.token }}
DEFAULT_BRANCH: ${{ inputs.base_branch || github.event.repository.default_branch }}
DRY_RUN: ${{ inputs.dry_run == true }}
MAX_PRS: ${{ inputs.max_prs || '100' }}
PROJECT_FLOW: ${{ vars.PROJECT_FLOW || 'git-flow' }}
TRIGGER_REVIEWS: ${{ github.event_name != 'workflow_dispatch' || inputs.trigger_reviews == true }}
ENABLE_AUTO_MERGE: ${{ github.event_name != 'workflow_dispatch' || inputs.enable_auto_merge == true }}
UPDATE_BRANCHES: ${{ github.event_name != 'workflow_dispatch' || inputs.update_branches == true }}
PROJECT_FLOW: ${{ inputs.project_flow || vars.PROJECT_FLOW || 'git-flow' }}
TRIGGER_REVIEWS: ${{ github.event_name == 'schedule' || inputs.trigger_reviews == true }}
ENABLE_AUTO_MERGE: ${{ github.event_name == 'schedule' || inputs.enable_auto_merge == true }}
UPDATE_BRANCHES: ${{ github.event_name == 'schedule' || inputs.update_branches == true }}
STALE_OPENCODE_MINUTES: ${{ inputs.stale_opencode_minutes || vars.STALE_OPENCODE_MINUTES || '45' }}
CANONICAL_REF: ${{ inputs.canonical_ref || 'main' }}
steps:
- name: Checkout trusted scheduler
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ContextualWisdomLab/.github
ref: ${{ env.CANONICAL_REF }}
fetch-depth: 1

- name: Self-test scheduler
Expand Down
Loading