Skip to content

Commit 3261852

Browse files
authored
Enhance workflow to get PR info before checkout
Added steps to retrieve pull request information before checking out the PR head.
1 parent e456c00 commit 3261852

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

.github/workflows/build-bootJar-on-comment.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,30 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- name: Checkout repository with full history
23-
uses: actions/checkout@v4
22+
- name: Get PR info
23+
id: pr
24+
uses: actions/github-script@v7
2425
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
script: |
28+
const prNumber = context.issue.number;
29+
const pr = await github.rest.pulls.get({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
pull_number: prNumber,
33+
});
34+
35+
core.info(`Base: ${pr.data.base.repo.full_name}@${pr.data.base.ref}`);
36+
core.info(`Head: ${pr.data.head.repo.full_name}@${pr.data.head.ref}`);
37+
38+
core.setOutput('head_ref', pr.data.head.ref);
39+
core.setOutput('head_repo', pr.data.head.repo.full_name);
40+
41+
- name: Checkout PR head with full history
42+
uses: actions/checkout@v5
43+
with:
44+
repository: ${{ steps.pr.outputs.head_repo }}
45+
ref: ${{ steps.pr.outputs.head_ref }}
2546
fetch-depth: 0
2647
fetch-tags: true
2748

0 commit comments

Comments
 (0)