Skip to content

Commit

Permalink
Correctly set the ref (branch) when using workflow dispatch (#5953)
Browse files Browse the repository at this point in the history
`github.head_ref` is empty when using workflow dispatch to trigger the
workflow. According to
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context,
`github.head_ref is only available when the event that triggers a
workflow run is either `pull_request` or `pull_request_target`.

The fix is to do the same as SHA by checking for the event name and set
the branch accordingly.

### Testing


https://github.com/pytorch/pytorch/actions/workflows/inductor-perf-test-nightly-macos.yml
at https://github.com/pytorch/pytorch/actions/runs/11939943706
  • Loading branch information
huydhn authored Nov 20, 2024
1 parent e0d02f1 commit 5ff1c7e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .github/actions/upload-benchmark-results/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ runs:
env:
SCHEMA_VERSION: ${{ inputs.schema-version }}
REPO: ${{ github.repository }}
HEAD_BRANCH: ${{ github.head_ref }}
HEAD_BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
WORKFLOW_RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
Expand Down

0 comments on commit 5ff1c7e

Please sign in to comment.