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

`
  
      
  1. description: Run simple scripts using the GitHub client

  2. branding:

  3. color: blue

  4. icon: code

  5. inputs:

  6. script:

  7. description: The script to run

  8. required: true

  9. github-token:

  10. description: The GitHub token used to create an authenticated client

  11. default: ${{ github.token }}

  12. required: false

  13. debug:

  14. description: Whether to tell the GitHub client to log details of its requests

  15. default: false

  16. user-agent:

  17. description: An optional user-agent string

  18. default: actions/github-script

  19. previews:

  20. description: A comma-separated list of API previews to accept

  21. result-encoding:

    `

That’s ok if it makes sense to give users of the action the option to override the default value.