fix(pr-autodiff): make sure compare does correctly
This commit is contained in:
parent
2fad2904d7
commit
d7b3f9a5c3
20
.github/workflows/pr-autodiff.yaml
vendored
20
.github/workflows/pr-autodiff.yaml
vendored
@ -15,21 +15,20 @@ jobs:
|
|||||||
(github.event_name == 'pull_request') ||
|
(github.event_name == 'pull_request') ||
|
||||||
(github.event_name == 'issue_comment' &&
|
(github.event_name == 'issue_comment' &&
|
||||||
contains(github.event.comment.body, '!pr-diff') &&
|
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)
|
github.event.issue.pull_request)
|
||||||
steps:
|
steps:
|
||||||
- name: Get PR head SHA
|
- name: Get PR head SHA
|
||||||
id: get-pr-sha
|
id: get-pr-sha
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
PR_URL="${{ github.event.issue.pull_request.url || github.event.pull_request.url }}"
|
||||||
echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
|
# https://api.github.com/repos/OpenManus/pulls/1
|
||||||
echo "Retrieved PR head SHA: ${{ github.event.pull_request.head.sha }}"
|
RESPONSE=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL)
|
||||||
else
|
SHA=$(echo $RESPONSE | jq -r '.head.sha')
|
||||||
PR_URL="${{ github.event.issue.pull_request.url }}"
|
TARGET_BRANCH=$(echo $RESPONSE | jq -r '.base.ref')
|
||||||
SHA=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL | jq -r '.head.sha')
|
|
||||||
echo "pr_sha=$SHA" >> $GITHUB_OUTPUT
|
echo "pr_sha=$SHA" >> $GITHUB_OUTPUT
|
||||||
echo "Retrieved PR head SHA from API: $SHA"
|
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
|
||||||
fi
|
echo "Retrieved PR head SHA from API: $SHA, target branch: $TARGET_BRANCH"
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@ -49,6 +48,7 @@ jobs:
|
|||||||
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
|
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
|
||||||
|
TARGET_BRANCH: ${{ steps.get-pr-sha.outputs.target_branch }}
|
||||||
run: |-
|
run: |-
|
||||||
cat << 'EOF' > /tmp/_workflow_core.py
|
cat << 'EOF' > /tmp/_workflow_core.py
|
||||||
import os
|
import os
|
||||||
@ -59,7 +59,7 @@ jobs:
|
|||||||
|
|
||||||
def get_diff():
|
def get_diff():
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
['git', 'diff', 'origin/main...HEAD'],
|
['git', 'diff', 'origin/' + os.getenv('TARGET_BRANCH') + '...HEAD'],
|
||||||
capture_output=True, text=True, check=True)
|
capture_output=True, text=True, check=True)
|
||||||
return '\n'.join(
|
return '\n'.join(
|
||||||
line for line in result.stdout.split('\n')
|
line for line in result.stdout.split('\n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user