Skip to content
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

Are github.head_ref and github.base_ref null when not a pull request? #13810

Closed
1 task done
dlech opened this issue Jan 7, 2022 · 6 comments
Closed
1 task done

Are github.head_ref and github.base_ref null when not a pull request? #13810

dlech opened this issue Jan 7, 2022 · 6 comments
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team waiting for review Issue/PR is waiting for a writer's review

Comments

@dlech
Copy link

dlech commented Jan 7, 2022

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

What part(s) of the article would you like to see updated?

The base_ref or target branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is either pull_request or pull_request_target.

Stating that the property is not available is ambiguous. If I use ${{ github.base_ref }} in an action, does it return null, does it cause an error, or something else if the trigger is not a pull request?

Additional information

The same clarification is needed for github.base_ref.

@dlech dlech added the content This issue or pull request belongs to the Docs Content team label Jan 7, 2022
@welcome
Copy link

welcome bot commented Jan 7, 2022

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team. label Jan 7, 2022
@github-actions github-actions bot added this to Triage in Docs open source board Jan 7, 2022
@ramyaparimi ramyaparimi added actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team. labels Jan 10, 2022
@ramyaparimi
Copy link
Contributor

@dlech
Thanks so much for opening an issue! I'll triage this for the team to take a look 👀

@skedwards88
Copy link
Contributor

Yep! The docs have now .been updated to state this.

Docs open source board automation moved this from Triage to Done Jan 31, 2022
@YashNagayach95
Copy link

YashNagayach95 commented Jul 5, 2022

@ramyaparimi @dlech @skedwards88
How to get the target branch on push event (Not a PR yet)?
Target branch here I mean is main branch from where I created my own foo branch.
I need the target branch so that I can calculate the baseBranchCoverage on every push event.
Any suggestions?

@dlech
Copy link
Author

dlech commented Jul 5, 2022

Branches by definition do not have a target, so you will need to get this information from somewhere else. For example, we just assume that the default branch (e.g. main or master) is the base branch.

@cmwilson21
Copy link
Collaborator

@YashNagayach95 👋 This question would best be handled by our support team. Please reach out to them.

If there's anything in the documents that you have suggestions for updating, please feel free to open an issue. 💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team waiting for review Issue/PR is waiting for a writer's review
Development

No branches or pull requests

5 participants