Skip to content

Commit 1f6918c

Browse files
[CI] Fix E2E workflows on PR trigger
By default 'issue_comment' trigger gets the context of a default branch. If we want to test the actual PR, on which we created/edited a comment we have to fetch and checkout a special ref for PR's merge commit. Note, that 'pull/<no>/merge' ref is available as long as the PR is not merged. This commit do not take this under consideration, since this case should be fairly uncommon and would obfuscate the workflow.
1 parent cc268e5 commit 1f6918c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

.github/workflows/e2e_core.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ jobs:
6666
ls -la ./
6767
rm -rf ./* || true
6868
69-
- uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v2.0.0
70-
id: comment-branch
71-
if: ${{ always() && inputs.trigger != 'schedule' }}
72-
7369
- name: Add comment to PR
7470
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
7571
if: ${{ always() && inputs.trigger != 'schedule' }}
@@ -90,7 +86,18 @@ jobs:
9086
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
9187
with:
9288
path: ur-repo
93-
ref: ${{ steps.comment-branch.outputs.head_ref }}
89+
90+
# On issue_comment trigger (for PRs) we need to fetch special ref for
91+
# proper PR's merge commit. Note, this ref may be absent if the PR is already merged.
92+
- name: Fetch PR's merge commit
93+
if: ${{ inputs.trigger != 'schedule' }}
94+
working-directory: ${{github.workspace}}/ur-repo
95+
env:
96+
PR_NO: ${{github.event.issue.number}}
97+
run: |
98+
git fetch -- https://github.com/${{github.repository}} +refs/pull/${PR_NO}/*:refs/remotes/origin/pr/${PR_NO}/*
99+
git checkout origin/pr/${PR_NO}/merge
100+
git rev-parse origin/pr/${PR_NO}/merge
94101
95102
- name: Checkout SYCL
96103
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

0 commit comments

Comments
 (0)