Skip to content

Commit 6939f88

Browse files
authored
Update clang-format-diff-apply.yml
Get pullrequest info with actions/checkout#331 (comment)
1 parent ec1c3ca commit 6939f88

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/clang-format-diff-apply.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,28 @@ jobs:
4242
if: ${{ startsWith(github.event.comment.body, '@apply-formatting<!--LLVM CODE FORMAT COMMENT:') }}
4343
runs-on: ubuntu-latest
4444
steps:
45-
45+
- uses: actions/github-script@v3
46+
id: get-pr
47+
with:
48+
script: |
49+
const request = {
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
pull_number: context.issue.number
53+
}
54+
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
55+
try {
56+
const result = await github.pulls.get(request)
57+
return result.data
58+
} catch (err) {
59+
core.setFailed(`Request failed with error ${err}`)
60+
}
4661
- name: Fetch LLVM sources
4762
uses: actions/checkout@v4
4863
with:
4964
fetch-depth: 2
50-
ref: ${{ github.event.pull_request.head.ref }}
51-
repository: ${{ github.event.pull_request.head.repo.full_name }}
65+
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
66+
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }}
5267

5368
- name: Setup Python env
5469
uses: actions/setup-python@v4
@@ -72,6 +87,6 @@ jobs:
7287
- name: Commit & Push changes
7388
uses: actions-js/push@master
7489
with:
75-
branch: test21
76-
repository: ${{ github.event.pull_request.head.repo.full_name }}
90+
branch: ${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
91+
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }}
7792
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)