Visualizing the github object #27206
-
I come from JS development and I have a habit of digging, inside the dev tools, into objects to see their props and methods, so that I could use them for whatever functionality I wanted to create. In GHActions, I understood that there is this workflow context object github, which encompasses everything that happens like events, repo data etc. Currently, I am trying to create a logic for some of the steps inside a workflow and I would like to if I can base it on information the github object can provide. Is there any, hopefully as straightforward as objects in dev tools, way to visualize and rummage through the whole github object, optimally in real time ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I know that this likely doesn’t answer your question, but I am not aware of such tool existing, but you can always write a small node script which logs it out. Probably you could also utilise Github’s toolkit for that: https://github.com/actions/toolkit/blob/8d11ee5a8c46598f9c08f0905995c84f3352cff0/packages/github/src/context.ts#L6 On the other hand documentation on the context is rather solid, and we rarely had to dig into internals to find out what it’s composed from: Context and expression syntax for GitHub Actions - GitHub DocsMaybe you could describe your usecase a bit better? |
Beta Was this translation helpful? Give feedback.
-
How would you go about doing this ? - “small node script which logs it out” So far, sounds like this would solve my conundrum, the best. As far as particular usecase, I was thinking more in general, but currently I am trying to solve this and couldn’t figure it out using the docs myself:
I would like a certain step in my workflow to execute only on PRs from currentRepo/feature/branch to currentRepo/master (currentRepo is a fork!) and NOT EXECUTE on PRs from currentRepo/feature/branch to upstream/master. Is there a way to distinguish between the two PRs ? |
Beta Was this translation helpful? Give feedback.
-
So as I mentioned above you can use actions/toolkit - TypeScript Action WalkthroughThe GitHub ToolKit for developing GitHub Actions. Contribute to actions/toolkit development by creating an account on GitHub. Then to make this even more lo-key investment and don’t do bundling you could use actions/github-scriptWrite workflows scripting the GitHub API in JavaScript When it comes to your specific usecase, I believe you need an “if” with particular assertions agaist Docs on “if”: Workflow syntax for GitHub Actions - GitHub Docs//docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions You might also want to have a look at available functions for expressions inside “if” statements, in this case Context and expression syntax for GitHub Actions - GitHub Docs |
Beta Was this translation helpful? Give feedback.
So as I mentioned above you can use
github.comactions/toolkit
to access github context in node, that’s one way:actions/toolkit - TypeScript Action Walkthrough
The GitHub ToolKit for developing GitHub Actions. Contribute to actions/toolkit development by creating an account on GitHub.
Then to make this even more lo-key investment and don’t do bundling you could use
github.comacitons/github-script
to access toolkit inline inside yaml, as you can see bothgithub
andcontext
are parts of the arguments:actions/github-script
Write workflows scripting the GitHub API in JavaScript
When it comes to your specific usecase, I believe you need an “if” with particular assertions agaist
g…