Skip to content

GH1090 Fix comment commands not checking out the correct branch #1094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions .github/workflows/comment_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,10 @@ jobs:
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body)

steps:
- uses: actions/checkout@v4

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: "3.11"

- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
# run the tests based on the value of the comment
id: tests-step
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}

- name: Get head sha and store value
- name: Get head sha, branch name and store value
# get the sha of the last commit to attach the results of the tests
if: always()
id: get-sha
id: get-branch-info
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -48,6 +35,25 @@ jobs:
pull_number: ${{ github.event.issue.number }}
})
core.setOutput('sha', pr.data.head.sha)
core.setOutput('branch', pr.data.head.ref)

- name: Checkout code on the correct branch
uses: actions/checkout@v4
with:
# context is not aware which branch to checkout so it would otherwise
# default to main
ref: ${{ steps.get-branch-info.outputs.branch }}

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: "3.12"

- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
# run the tests based on the value of the comment
id: tests-step
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}

- name: Report results of the tests and publish
# publish the results to a check run no matter the pass or fail
Expand All @@ -58,7 +64,7 @@ jobs:
script: |
github.rest.checks.create({
name: '${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}',
head_sha: '${{ steps.get-sha.outputs.sha }}',
head_sha: '${{ steps.get-branch-info.outputs.sha }}',
status: 'completed',
conclusion: '${{ steps.tests-step.outcome }}',
output: {
Expand Down
Loading