Skip to content

Commit ccb933a

Browse files
authored
add pr head commit hash check (#298)
## 📝 Description Add PR head commit hash check ## ✔️ How to Test **What are the steps to reproduce the issue or verify the changes?** **How do I run the relevant unit/integration tests?** ## 📷 Preview **If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.**
1 parent f45ae85 commit ccb933a

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/e2e-test-pr.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions-ecosystem/action-regex-match@v2
2525
id: validate-tests
2626
with:
27-
text: ${{ github.event.client_payload.slash_command.tests }}
27+
text: ${{ inputs.test_path }}
2828
regex: '[^a-z0-9-:.\/_]' # Tests validation
2929
flags: gi
3030

@@ -34,6 +34,31 @@ jobs:
3434
with:
3535
ref: ${{ inputs.sha }}
3636

37+
- name: Get the hash value of the latest commit from the PR branch
38+
uses: octokit/graphql-action@v2.x
39+
id: commit-hash
40+
if: ${{ inputs.pull_request_number != '' }}
41+
with:
42+
query: |
43+
query PRHeadCommitHash($owner: String!, $repo: String!, $pr_num: Int!) {
44+
repository(owner:$owner, name:$repo) {
45+
pullRequest(number: $pr_num) {
46+
headRef {
47+
target {
48+
... on Commit {
49+
oid
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
owner: ${{ github.event.repository.owner.login }}
57+
repo: ${{ github.event.repository.name }}
58+
pr_num: ${{ fromJSON(inputs.pull_request_number) }}
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
3762
- name: Update system packages
3863
run: sudo apt-get update -y
3964

@@ -60,7 +85,7 @@ jobs:
6085

6186
- uses: actions/github-script@v6
6287
id: update-check-run
63-
if: ${{ inputs.pull_request_number != '' }}
88+
if: ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
6489
env:
6590
number: ${{ inputs.pull_request_number }}
6691
job: ${{ github.job }}

0 commit comments

Comments
 (0)