Skip to content

feat(server): send rich text to Matrix with sanitized formatted_body #1684

feat(server): send rich text to Matrix with sanitized formatted_body

feat(server): send rich text to Matrix with sanitized formatted_body #1684

Workflow file for this run

name: PR Babysitter
on:
workflow_dispatch:
inputs:
pr_number:
description: "Pull request number to maintain"
required: true
type: number
pull_request_review:
types: [submitted]
permissions:
contents: write
issues: read
pull-requests: write
actions: read
checks: read
jobs:
resolve:
name: Resolve PR
runs-on: ubuntu-24.04
outputs:
pr_number: ${{ steps.resolve.outputs.pr_number }}
should_run: ${{ steps.resolve.outputs.should_run }}
steps:
- id: resolve
name: Resolve PR number
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
DISPATCH_PR: ${{ github.event.inputs.pr_number }}
REVIEW_PR_NUMBER: ${{ github.event.pull_request.number }}
REVIEW_AUTHOR: ${{ github.event.review.user.login }}
REVIEW_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
REPOSITORY: ${{ github.repository }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
TRUSTED_BABYSITTER_ACTORS: ${{ vars.CODEX_BABYSITTER_ACTORS }}
run: |
set -euo pipefail
should_run=false
pr_number=""
trusted_actors=",${TRUSTED_BABYSITTER_ACTORS:-},$REPOSITORY_OWNER,wizzoapp[bot],"
actor_is_trusted() {
local actor="$1"
local association="$2"
if [[ -n "$actor" && "$trusted_actors" == *",$actor,"* ]]; then
return 0
fi
case "$association" in
OWNER|MEMBER|COLLABORATOR)
return 0
;;
*)
return 1
;;
esac
}
reviewer_is_trusted() {
local actor="$1"
local trusted_reviewer
for trusted_reviewer in greptile-apps 'greptile-apps[bot]' 'chatgpt-codex-connector[bot]' codex 'codex[bot]'; do
if [[ "$actor" == "$trusted_reviewer" ]]; then
return 0
fi
done
actor_is_trusted "$actor" ""
}
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
should_run=true
pr_number="$DISPATCH_PR"
elif [[ "$EVENT_NAME" == "pull_request_review" ]]; then
if [[ "$REVIEW_HEAD_REPO" == "$REPOSITORY" ]] && reviewer_is_trusted "$REVIEW_AUTHOR"; then
should_run=true
pr_number="$REVIEW_PR_NUMBER"
fi
fi
echo "should_run=$should_run" >> "$GITHUB_OUTPUT"
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
babysit:
name: Babysit PR
needs: resolve
if: needs.resolve.outputs.should_run == 'true'
uses: ./.github/workflows/reusable-pr-babysitter.yml
with:
pr_number: ${{ fromJSON(needs.resolve.outputs.pr_number) }}
secrets: inherit