-
The below is the actions script where I need the username of github based on schedule event. Under “Set git username and email”, How do I get the github username?
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
Hey @byteshiva, I am a little confused. Is the existing setup you are using not working? If not, who’s username do you want? If the action is scheduled, then it’s not being triggered by a different user, so why not just hardcode it? |
Beta Was this translation helpful? Give feedback.
-
Hi @byteshiva , You can check the github context to get the event info. For GH username, you can follow the context structure and get it with below code:
There is no ‘user.login’ under ‘github.event.schedule’ from the context screenshot attached, that’s why you cannot get the value correctly. Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
Hey @byteshiva, I am a little confused. Is the existing setup you are using not working? >> The setup I’ve posted is not working If not, who’s username do you want? >> I want to get owner/username of the repo. If the action is scheduled, then it’s not being triggered by a different user, so why not just hardcode it? >> I don’t want to hardcode, since it can forked and used by other users as well. The forked user should be able to get their information. |
Beta Was this translation helpful? Give feedback.
-
Hi @byteshiva , The schedule event works on default branch(master), please make sure you check in correct branch. Use ‘${{ github.actor }}’ instead of ‘${{ github.event.schedule.user.login }}’ in your code. |
Beta Was this translation helpful? Give feedback.
-
Thanks @weide-zhou , - I’ve added the ${{github.actor}} to get the username and have placed it in main action script and waiting for the job to be run. I’ve tested it in standalone scripts. its working. |
Beta Was this translation helpful? Give feedback.
-
Hi @byteshiva , Thanks for your reply! Glad to know it works for you! More info for you, if you’d like to schedule for other branches than default master, there’s a trick that add ‘ref’ parameter for the ‘actions/checkout’, specify the desired branch as the value. Hope it helps! BTW, could you please help to mark then it can help others who has same query? Thanks. |
Beta Was this translation helpful? Give feedback.
Thanks @weide-zhou , - I’ve added the ${{github.actor}} to get the username and have placed it in main action script and waiting for the job to be run. I’ve tested it in standalone scripts. its working.