@@ -13,38 +13,37 @@ jobs:
13
13
runs-on : ubuntu-latest
14
14
timeout-minutes : 10
15
15
steps :
16
- - name : Get PR details
17
- id : get_pr
18
- uses : actions/github-script@v6
16
+ - uses : actions/github-script@v6
17
+ id : set-target-branch
19
18
with :
19
+ github-token : ${{secrets.GITHUB_TOKEN}}
20
+ result-encoding : string
20
21
script : |
21
- const pr_url = github.event.issue.pull_request.url;
22
- const pr = await github.request(`GET ${pr_url}`, {
23
- headers: {
24
- authorization: `token ${process.env.GITHUB_TOKEN}`
25
- }
26
- });
27
- return { base_ref: pr.data.base.ref, head_ref: pr.data.head.ref };
28
-
22
+ const pull_request = await github.pulls.get({
23
+ owner: context.repo.owner,
24
+ repo: context.repo.repo,
25
+ pull_number: context.issue.number
26
+ })
27
+ return {head_ref: pull_request.data.head.ref, base_ref: pull_request.data.base.ref}
29
28
- name : Output refs
30
- if : steps.get_pr .outputs.base_ref != ''
29
+ if : steps.set-target-branch .outputs.base_ref != ''
31
30
run : |
32
- echo "Base ref: ${{ steps.get_pr .outputs.base_ref }}"
33
- echo "Head ref: ${{ steps.get_pr .outputs.head_ref }}"
31
+ echo "Base ref: ${{ steps.set-target-branch .outputs.base_ref }}"
32
+ echo "Head ref: ${{ steps.set-target-branch .outputs.head_ref }}"
34
33
- uses : actions/checkout@v4
35
- name : checkout "${{ steps.get_pr .outputs.base_ref }}"
34
+ name : checkout "${{ steps.set-target-branch .outputs.base_ref }}"
36
35
with :
37
36
fetch-depth : 1
38
- ref : ${{ steps.get_pr .outputs.base_ref }}
37
+ ref : ${{ steps.set-target-branch .outputs.base_ref }}
39
38
- uses : actions/checkout@v4
40
- name : checkout "${{ steps.get_pr .outputs.head_ref }}"
39
+ name : checkout "${{ steps.set-target-branch .outputs.head_ref }}"
41
40
with :
42
41
fetch-depth : 1
43
- ref : ${{ steps.get_pr .outputs.head_ref }}
42
+ ref : ${{ steps.set-target-branch .outputs.head_ref }}
44
43
- name : check_diff
45
44
shell : bash
46
45
run : |
47
- files=(`git diff origin/${{ steps.get_pr .outputs.base_ref }} --name-only|tr '\n' ' ' `)
46
+ files=(`git diff origin/${{ steps.set-target-branch .outputs.base_ref }} --name-only|tr '\n' ' ' `)
48
47
for file in ${files[@]}; do
49
48
echo ${file}
50
49
done
0 commit comments