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

Get branch on context object. #103

Closed
Milo123459 opened this issue Nov 26, 2020 · 5 comments
Closed

Get branch on context object. #103

Milo123459 opened this issue Nov 26, 2020 · 5 comments

Comments

@Milo123459
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I need to get the branch that triggered the event, ie context.branch
Describe the solution you'd like
A clear and concise description of what you want to happen.
For instance, dependabot making a PR, I have a script to git-checkout to it but I need to get the branch.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@Milo123459
Copy link
Author

@jclem Is this already added? Is there another way to get it?

@jclem
Copy link
Contributor

jclem commented Dec 10, 2020

@Milo123459 Can you please fill out the questions in the issue template? I unfortunately don't understand what exactly it is you're asking, I'm sorry!

@Milo123459
Copy link
Author

@Milo123459 Can you please fill out the questions in the issue template? I unfortunately don't understand what exactly it is you're asking, I'm sorry!

Sorry for the late response,I just want something like context.branch that tells you the branch name from a PR

@huonw
Copy link

huonw commented Jan 12, 2021

More generally, it appears there's various properties available on github for YAML substitution, that aren't available on context in github-script: comparing https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context and https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts this includes:

  • action
  • action_path
  • actor
  • base_ref
  • head_ref
  • workflow
  • workspace

As a work-around, I think these are available as process.env.GITHUB_...: https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables. (This issue may be better suited to the https://github.com/actions/toolkit repo, and overlaps with, for instance, actions/toolkit#555)

@jclem
Copy link
Contributor

jclem commented Jan 13, 2021

Yeah that's correct. I don't plan on keeping that object in sync with what Actions calls the "GitHub context". Same word, but I'm using it to refer to something else. You can use YAML substitution in your script value in the config file, or as you say pull values out of the environment.

@jclem jclem closed this as completed Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants