diff --git a/.github/workflows/pr-autodiff.yaml b/.github/workflows/pr-autodiff.yaml index 85c79d0..46c95c6 100644 --- a/.github/workflows/pr-autodiff.yaml +++ b/.github/workflows/pr-autodiff.yaml @@ -15,21 +15,20 @@ jobs: (github.event_name == 'pull_request') || (github.event_name == 'issue_comment' && contains(github.event.comment.body, '!pr-diff') && - (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && + (github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && github.event.issue.pull_request) steps: - name: Get PR head SHA id: get-pr-sha run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT - echo "Retrieved PR head SHA: ${{ github.event.pull_request.head.sha }}" - else - PR_URL="${{ github.event.issue.pull_request.url }}" - SHA=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL | jq -r '.head.sha') - echo "pr_sha=$SHA" >> $GITHUB_OUTPUT - echo "Retrieved PR head SHA from API: $SHA" - fi + PR_URL="${{ github.event.issue.pull_request.url || github.event.pull_request.url }}" + # https://api.github.com/repos/OpenManus/pulls/1 + RESPONSE=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL) + SHA=$(echo $RESPONSE | jq -r '.head.sha') + TARGET_BRANCH=$(echo $RESPONSE | jq -r '.base.ref') + echo "pr_sha=$SHA" >> $GITHUB_OUTPUT + echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT + echo "Retrieved PR head SHA from API: $SHA, target branch: $TARGET_BRANCH" - name: Check out code uses: actions/checkout@v4 with: @@ -49,6 +48,7 @@ jobs: OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }} GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} + TARGET_BRANCH: ${{ steps.get-pr-sha.outputs.target_branch }} run: |- cat << 'EOF' > /tmp/_workflow_core.py import os @@ -59,7 +59,7 @@ jobs: def get_diff(): result = subprocess.run( - ['git', 'diff', 'origin/main...HEAD'], + ['git', 'diff', 'origin/' + os.getenv('TARGET_BRANCH') + '...HEAD'], capture_output=True, text=True, check=True) return '\n'.join( line for line in result.stdout.split('\n')