Manipulate event data in python

How can I send ${{github.event}} to a python file and manipulate that data with python?

One way can be to pass this information via env keyword and then access it in python with os.environ.

In Action, set github as an environment variable:

- name: pass env variable to python
  env: 
    GITHUB_CONTEXT: ${{ toJson(github) }}
  run: python test.py

In Python, you can access this with os.environ

import os
print(os.environ['GITHUB_CONTEXT'])
2 Likes

Thanks @ahdbilal , helped me a lot!

Do you know if there is any way to know the amount of comments opened by a user in an issue? And the number of issues opened by a user?

@allisonsampaio,

Do you know if there is any way to know the amount of comments opened by a user in an issue? And the number of issues opened by a user?

You can try to use the “List issue comments” API to list all the comments on a specified issue.
From the response of the API, you can see the details of each comment, include the comment body and the information of the user who added the comment.

You can traverse all the comments listed, and count the data you need.

1 Like