Skip to content

Commit d79cfea

Browse files
GH1090 Fix comment commands not checking out the correct branch
1 parent 3f42941 commit d79cfea

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

.github/workflows/comment_commands.yml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,10 @@ jobs:
2121
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body)
2222

2323
steps:
24-
- uses: actions/checkout@v4
25-
26-
- name: Install project dependencies
27-
uses: ./.github/setup
28-
with:
29-
os: ubuntu-latest
30-
python-version: "3.11"
31-
32-
- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
33-
# run the tests based on the value of the comment
34-
id: tests-step
35-
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}
36-
37-
- name: Get head sha and store value
24+
- name: Get head sha, branch name and store value
3825
# get the sha of the last commit to attach the results of the tests
3926
if: always()
40-
id: get-sha
27+
id: get-branch-info
4128
uses: actions/github-script@v7
4229
with:
4330
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -48,6 +35,23 @@ jobs:
4835
pull_number: ${{ github.event.issue.number }}
4936
})
5037
core.setOutput('sha', pr.data.head.sha)
38+
core.setOutput('branch', pr.data.head.ref)
39+
40+
- name: Checkout code on the correct branch
41+
uses: actions/checkout@v4
42+
with:
43+
ref: ${{ steps.get-branch-info.outputs.branch }}
44+
45+
- name: Install project dependencies
46+
uses: ./.github/setup
47+
with:
48+
os: ubuntu-latest
49+
python-version: "3.11"
50+
51+
- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
52+
# run the tests based on the value of the comment
53+
id: tests-step
54+
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}
5155

5256
- name: Report results of the tests and publish
5357
# publish the results to a check run no matter the pass or fail
@@ -58,7 +62,7 @@ jobs:
5862
script: |
5963
github.rest.checks.create({
6064
name: '${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}',
61-
head_sha: '${{ steps.get-sha.outputs.sha }}',
65+
head_sha: '${{ steps.get-branch-info.outputs.sha }}',
6266
status: 'completed',
6367
conclusion: '${{ steps.tests-step.outcome }}',
6468
output: {

0 commit comments

Comments
 (0)