How to programmatically delete a webhook

Hi there,

I’m trying to figure out how to clean up webhooks after a build has finished but without any user interaction. I can see that the command eas webhook:delete accepts an ID but is there a way to get that ID programmatically? The only option I can see from the docs is to manually run the list command and then use the ID listed there.

Is there anyway to delete all webhooks associated with a particular URL as that would then be easy to accomplish without any manual intervention?

This is a managed project where builds are automated and it always installs the latest eas-cli before running.

Thanks,

So I guess the answer to this is no, there is no way to delete a webhook without some manual intervention?

Is this something that can be introduced? There is a limit of only 10 webhooks per project so surely there needs to be an automated way to clear them once no longer needed?

hi there!

you can use eas webhook:list to list out the webhooks. you can filter by event type, build or submit, with the --event BUILD or --event SUBMIT flags.

currently this command does not support the --json flag but this would be a nice addition for it to be easily parseable. for now, you can parse the output as is.

Hi brents,

Thanks for the clarification. So for now we will need to create a script to parse the output of the list command to obtain the ID and then trigger the delete command for each ID.

+1 for adding JSON support. Is that a planned enhancement or just an idea?

it’s not actively planned but it’s something we support for other commands, such as eas build:list --json --non-interactive. if you’d like to open a pr to add support to the webhook:list command it would be welcome! i would suggest looking at how it’s built in build:list and making it as similar as possible

Hi brents,

I’ve now done this locally using my personal github account. However, I get a 403 error when trying to push my branch to create a Pull Request. Are you able to give me access? This is my personal github: sheddy7 (Simon Blake) · GitHub

Thanks and HNY

Hi @johnbuilder

I assume the repository is private? I don’t see anything that looks relevant at the above link.

  • I assume you forked the expo/expo repository, right?
  • Then you cloned your copy of the repository to your local machine? You can do this over HTTPS, but I prefer to use SSH because I’m familiar with SSH keys, agents, etc.
  • Ideally you would have then created a new branch called something like sheddy7/add-delete-option-to-webhook-list
  • Then you would have made your changes on this new branch
  • Then you should be able to push. Here you are pushing to your own repository, so the Expo team is unable to give you access. As long as your authentication is setup OK, you will be able to push.
  • After you push, you should see a message in the console that gives you a GitHub URL to click on that will allow you to create the PR.

You can run git remote -v to see what protocol you used.

  • SSH looks something like: git@github.com:username/repository-name.git
  • HTTPS looks something like: https://github.com/username/repository-name.git

The 403 error suggests to me that you’re using HTTPS.

As far as I know if you clone over HTTPS and don’t do anything special (e.g. generating an access token etc.) it should prompt you for a username and password when you want to do something like push.

For more info about authenticating to GitHub, see About authentication to GitHub

I hope this helps.

2 Likes

Hi wodin,

Thank you for the step by step instructions, I had done them all apart from actually creating the fork to start with :disappointed:

I have now created the PR: https://github.com/expo/eas-cli/pull/1605

1 Like