empty github environment created for each deployment
Pullpreview seems to be creating an empty github deployment environment for each PR. This makes managing real environments rather difficult. What is the purpose and how can we prevent it altogether, or at least have them removed together with the deployment?
Hi, it's not empty at the time of deploy, but after the PullPreview env gets destroyed indeed it stays as an env, and has to be deleted manually from the Deployments UI. This is a limitation of the GitHub Token given to the PullPreview action, it does not allow removing deployments altogether (understandably since this could have nasty side-effects).
The only solution would be to allow PullPreview to get a PAT or GitHub App token, given as action input. But then that defeats a bit the simplicity, so not sure what to do yet.
got it. It was easy enough to delete them via the api, but it is definitely annoying. This worked for me:
gh api /repos/$ORG/$REPO/environments?per_page=100 |
jq -r '.environments[]|.name' |
grep -E '^gh-[0-9]+-pr-[0-9]+' |
while read env
do gh api --method DELETE /repos/$ORG/$REPO/environments/$env
done
How is the environment used?
This can now be auto-cleaned up via #89 and the use of a custom GitHub token (PAT or generated by https://github.com/actions/create-github-app-token) with the correct permissions.