pullpreview / action

A GitHub Action that starts preview deployments for your pull requests and branches. It can work with any application that has a valid Docker Compose file.
https://pullpreview.com
Other
164 stars 13 forks source link

Destroy expired environments #84

Closed leightjohnson93 closed 1 month ago

leightjohnson93 commented 2 months ago

The scheduled job doesn't seem to actually be cleaning up the expired ~environments~ instances. It just logs a message.

https://github.com/pullpreview/action/issues/83

crohr commented 2 months ago

@leightjohnson93 this is because the GitHub Token cannot perform the environment deletion. It can only delete deployments. There is a comment in the code about that:

# This requires repository permission, which the GitHub Action token cannot get, so cannot delete the environment unfortunately
leightjohnson93 commented 2 months ago

@crohr So I don't understand, what's the point of having ttl if it doesn't work? I really just want to delete the instance so we aren't wasting money.

I think I meant to say instances and deployments instead.

Could we just like, remove the label after ttl?

leightjohnson93 commented 2 months ago

@leightjohnson93 this is because the GitHub Token cannot perform the environment deletion. It can only delete deployments. There is a comment in the code about that:

# This requires repository permission, which the GitHub Action token cannot get, so cannot delete the environment unfortunately

What about the option to pass in our own github token with administrator permissions?

Alanoll commented 1 month ago

Could we add a new YAML option to attempt the deletion of the environment because we provided our own Github Token?

So:

There's already a YAML parameter github_token to provide a custom token.

This actions has steps to get a suitable token: https://github.com/marketplace/actions/delete-deployment-environment

crohr commented 1 month ago

@crohr So I don't understand, what's the point of having ttl if it doesn't work? I really just want to delete the instance so we aren't wasting money.

I think I meant to say instances and deployments instead.

Could we just like, remove the label after ttl?

Instances are destroyed with the TTL, but the GitHub environment object is not, since it requires permissions the GitHub context cannot have.

Could we add a new YAML option to attempt the deletion of the environment because we provided our own Github Token?

Yes, I will open a separate PR for that