File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : " PR Labeler"
22
33on :
4- pull_request :
4+ pull_request_target :
55 types : [opened, synchronize]
66
77jobs :
@@ -14,16 +14,21 @@ jobs:
1414 pull-requests : write
1515
1616 steps :
17- - name : Checkout code
17+ - name : Checkout PR head
1818 uses : actions/checkout@v4
1919 with :
20+ # Fetch the PR head so we can diff against the base
21+ ref : ${{ github.event.pull_request.head.sha }}
2022 fetch-depth : 0
2123
24+ - name : Fetch base branch
25+ run : git fetch origin ${{ github.event.pull_request.base.ref }}
26+
2227 - name : Get changed files
2328 id : changed
2429 run : |
2530 # Get the list of changed files in the PR
26- git diff --name-only origin/${{ github.base_ref }}...HEAD > changed_files.txt
31+ git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.event.pull_request.head.sha }} > changed_files.txt
2732 echo "Changed files:"
2833 cat changed_files.txt
2934
7479
7580 // Get the full diff
7681 const diff = execSync(
77- `git diff origin/${process.env.BASE_REF}...HEAD `,
82+ `git diff origin/${process.env.BASE_REF}...${process.env.HEAD_SHA} `,
7883 { encoding: 'utf8', maxBuffer: 10 * 1024 * 1024 }
7984 );
8085
@@ -251,4 +256,5 @@ jobs:
251256 }
252257 }
253258 env :
254- BASE_REF : ${{ github.base_ref }}
259+ BASE_REF : ${{ github.event.pull_request.base.ref }}
260+ HEAD_SHA : ${{ github.event.pull_request.head.sha }}
You can’t perform that action at this time.
0 commit comments