Accessing GH context in actions · community · Discussion #26326 (original) (raw)
I don’t think it’s currently possible to access the context directly.
Consider github-script, which provides a partial context containing some of the items from the workflow github context. That partial context is actually just rehydrated from the environment. If it were possible to get the real context directly it would make sense for github-script to do that. The fact it doesn’t suggests it’s not possible.
One workaround is to add inputs to your action, but set the default using the context, eg:
<a href="https://github.com/actions/github-script/blob/00e1b58cd9e040d944127e75b3d9df586e4b0479/action.yml#L13" target="_blank" rel="noopener nofollow ugc">github.com</a>
actions/github-script/blob/00e1b58cd9e040d944127e75b3d9df586e4b0479/action.yml#L13
`
description: Run simple scripts using the GitHub client
branding:
color: blue
icon: code
inputs:
script:
description: The script to run
required: true
github-token:
description: The GitHub token used to create an authenticated client
default: ${{ github.token }}
required: false
debug:
description: Whether to tell the GitHub client to log details of its requests
default: false
user-agent:
description: An optional user-agent string
default: actions/github-script
previews:
description: A comma-separated list of API previews to accept
result-encoding:
`
That’s ok if it makes sense to give users of the action the option to override the default value.