Skip to content

H-5998: Version fixes for JS package publishing #1971

H-5998: Version fixes for JS package publishing

H-5998: Version fixes for JS package publishing #1971

Workflow file for this run

name: AI PR Review
on:
pull_request:
types: [review_requested]
workflow_dispatch:
inputs:
pr_number:
description: Pull request number to review
required: true
type: number
# Prevent multiple AI review jobs from running simultaneously on the same PR
# This ensures reviews are sequential and prevents duplicate/conflicting reviews
concurrency:
# For workflow_dispatch events, we use github.ref (branch name)
# For pull_request events, we use the PR number
# This ensures a unique concurrency group per PR
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.pr_number || github.ref }}
# Don't cancel in-progress reviews, let them complete
# New reviews will wait in queue until active ones finish
cancel-in-progress: false
jobs:
check-conditions:
runs-on: ubuntu-24.04
outputs:
should_review: ${{ steps.set-output.outputs.should_review }}
steps:
- name: Set trigger type
id: trigger-type
env:
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "is_workflow_dispatch=true" >> $GITHUB_OUTPUT
else
echo "is_workflow_dispatch=false" >> $GITHUB_OUTPUT
fi
- name: Check branch name
id: check-branch
if: steps.trigger-type.outputs.is_workflow_dispatch != 'true'
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
echo "Branch name: $HEAD_REF"
if [[ "$HEAD_REF" == deps/* ]]; then
echo "❌ Branch starts with deps/"
echo "is_deps_branch=true" >> $GITHUB_OUTPUT
else
echo "✅ Branch does not start with deps/"
echo "is_deps_branch=false" >> $GITHUB_OUTPUT
fi
- name: Check if review is requested for hashdotai
id: check-reviewer
if: steps.trigger-type.outputs.is_workflow_dispatch != 'true'
env:
REVIEWER_LOGIN: ${{ github.event.requested_reviewer.login }}
run: |
echo "Requested reviewer: $REVIEWER_LOGIN"
if [[ "$REVIEWER_LOGIN" == "hashdotai" ]]; then
echo "✅ Review requested for hashdotai"
echo "is_hashdotai=true" >> $GITHUB_OUTPUT
else
echo "❌ Review not requested for hashdotai"
echo "is_hashdotai=false" >> $GITHUB_OUTPUT
fi
- name: Check PR author
id: check-maintainer
if: steps.trigger-type.outputs.is_workflow_dispatch != 'true' && steps.check-reviewer.outputs.is_hashdotai == 'true'
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Checking if $PR_AUTHOR is a maintainer on $REPO"
# Get the permission level of the PR author
PERMISSION=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO/collaborators/$PR_AUTHOR/permission" | \
jq -r '.permission')
# Check if the permission level indicates maintainer status (admin or write)
if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "write" ]]; then
echo "✅ $PR_AUTHOR is a maintainer"
echo "is_maintainer=true" >> $GITHUB_OUTPUT
else
echo "❌ $PR_AUTHOR is not a maintainer"
echo "is_maintainer=false" >> $GITHUB_OUTPUT
fi
- name: Set final output
id: set-output
env:
IS_WORKFLOW_DISPATCH: ${{ steps.trigger-type.outputs.is_workflow_dispatch }}
IS_HASHDOTAI: ${{ steps.check-reviewer.outputs.is_hashdotai }}
IS_MAINTAINER: ${{ steps.check-maintainer.outputs.is_maintainer }}
IS_DEPS_BRANCH: ${{ steps.check-branch.outputs.is_deps_branch }}
run: |
if [[ "$IS_WORKFLOW_DISPATCH" == "true" ]]; then
echo "✅ Workflow dispatch - will run AI review"
echo "should_review=true" >> $GITHUB_OUTPUT
else
# For pull_request event, check all conditions
if [[ "$IS_DEPS_BRANCH" == "true" ]]; then
echo "❌ Branch starts with deps/ - skipping review"
echo "should_review=false" >> $GITHUB_OUTPUT
elif [[ "$IS_HASHDOTAI" == "true" && "$IS_MAINTAINER" == "true" ]]; then
echo "✅ All conditions met - will run AI review"
echo "should_review=true" >> $GITHUB_OUTPUT
else
echo "❌ Conditions not met - will skip AI review"
echo "should_review=false" >> $GITHUB_OUTPUT
fi
fi
review:
needs: check-conditions
if: needs.check-conditions.outputs.should_review == 'true'
runs-on: ubuntu-24.04
permissions:
id-token: write
steps:
- name: Checkout source code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2
- name: Install tools
uses: ./.github/actions/install-tools
with:
token: ${{ secrets.GITHUB_TOKEN }}
vault_address: ${{ secrets.VAULT_ADDR }}
rust: false
- name: Warm up repository
uses: ./.github/actions/warm-up-repo
- name: Determine PR number
id: pr-number
env:
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_PR_NUMBER: ${{ github.event.inputs.pr_number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "number=$WORKFLOW_PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
fi
- name: Run AI Code PR Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
LINEAR_APPLICATION_ACCESS_TOKEN: ${{ secrets.LINEAR_APPLICATION_ACCESS_TOKEN }}
PR_NUMBER: ${{ steps.pr-number.outputs.number }}
GH_TOKEN: ${{ secrets.MACHINE_USER_TOKEN }}
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: yarn workspace @local/repo-chores exe scripts/ai-pr-review.ts "$PR_NUMBER"