refactor(trends): extract buildDerivedConfigs helper + perf fixes #16035
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Resolve outdated bot comments | |
| on: | |
| pull_request: | |
| types: [synchronize] | |
| permissions: | |
| contents: read | |
| jobs: | |
| resolve-outdated: | |
| name: Resolve outdated bot review comments | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' | |
| steps: | |
| - name: Get app token | |
| id: app-token | |
| uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 | |
| with: | |
| client-id: ${{ secrets.GH_APP_POSTHOG_REVIEW_COMMENT_RESOLVER_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_POSTHOG_REVIEW_COMMENT_RESOLVER_PRIVATE_KEY }} | |
| - name: Resolve outdated bot threads | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| BOTS="copilot-pull-request-reviewer greptile-apps chatgpt-codex-connector graphite-app cursor claude claude-code-action claude-review" | |
| OWNER="${REPO%/*}" | |
| REPO_NAME="${REPO#*/}" | |
| THREADS=$(gh api graphql -f query=' | |
| query($owner: String!, $repo: String!, $pr: Int!) { | |
| repository(owner: $owner, name: $repo) { | |
| pullRequest(number: $pr) { | |
| reviewThreads(first: 100) { | |
| pageInfo { hasNextPage } | |
| nodes { | |
| id | |
| isOutdated | |
| isResolved | |
| comments(first: 2) { | |
| totalCount | |
| nodes { | |
| author { login } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }' -f owner="$OWNER" -f repo="$REPO_NAME" -F pr="$PR_NUMBER") | |
| HAS_NEXT=$(echo "$THREADS" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.hasNextPage') | |
| if [ "$HAS_NEXT" = "true" ]; then | |
| echo "WARNING: more than 100 review threads found; some outdated bot threads may not be resolved" | |
| fi | |
| THREAD_IDS=$(echo "$THREADS" | jq -r --arg bots "$BOTS" ' | |
| .data.repository.pullRequest.reviewThreads.nodes[] | |
| | select(.isOutdated == true and .isResolved == false and .comments.totalCount == 1) | |
| | select(.comments.nodes[0].author.login as $author | ($bots | split(" ") | any(. == $author))) | |
| | .id | |
| ') | |
| if [ -z "$THREAD_IDS" ]; then | |
| echo "No outdated bot threads to resolve" | |
| exit 0 | |
| fi | |
| echo "$THREAD_IDS" | while read -r thread_id; do | |
| echo "Resolving thread $thread_id" | |
| gh api graphql -f query=' | |
| mutation($id: ID!) { | |
| resolveReviewThread(input: { threadId: $id }) { | |
| thread { isResolved } | |
| } | |
| }' -f id="$thread_id" | |
| done |