Hey folks, is there way to programmatically delete...
# ask-community
v
Hey folks, is there way to programmatically delete a branch deployment on dagster cloud? Need to be able to clean up dagster cloud when a github PR is merged. Thanks in advance!
🤖 1
b
Hi Vivek, the GitHub Actions for branch deployments should mark the branch as “closed” when a PR is merged/closed. That will hide it from the UI (& branch deployment agent infra spins down automatically after a timeout). Are you interested in explicitly deleting? Archiving is our default to keep e.g. run history around
v
Thanks for the reply Ben, based on what I can see, it looks like there a bug in hiding closed and merged branches. If it spins the agent, I think that’s fine, just want to have a view where it’s not spammy with old PRs
b
Do the branches show up as closed or merged in the UI? It may be an error in marking them as closed/merged on the GH Actions end.
đź‘Ť 1
Open branches will have this green icon
v
I might have to update my deployment agents to the latest version
right now if I toggle
Show closed and merged branches
off, I still see some that were merged.
b
Do they have the merged/closed icon? Just trying to determine where the error might be happening (e.g. they aren’t being marked merged/closed or they aren’t being hidden)
v
Screenshot 2023-03-30 at 4.26.12 PM.png
here’s what I see now
b
Hmm, yeah, it looks like we aren’t marking them as closed. Are you using the GitHub Action to create branch deployments?
v
yup using the action
If you can file a github issue for it, I can track the progress there, Thanks @ben!
b
I can do that! Do you see any failing github action runs for closed branches?
đź‘Ť 1
v
So the way I have it now is 3 actions
b
Set up tracking issue here
v
1 action for PR open
1 action for Merge into main branch
1 action for PR close
this might just be a configuration issue on my end
the PR close action is currently a stub
because it was unclear how PR open or Merge into main branch would handle
b
Ahh yeah that may be the case. The “create or update branch” action will tell Dagster that the PR is closed if the PR state is closed/merged
v
ahhh
where is the
create or update branch
action?
I’m trying to look for it
b
Ah sorry, the hybrid branch deploy action. It calls
create or update branch
internally (it’s a composite action)
Here you can see it passes the PR status alongside the PR info to update the status in Dagster Cloud: https://github.com/dagster-io/dagster-cloud-action/blob/main/actions/hybrid_branch_deploy/action.yml#LL69-L79C71
v
got it!
so basically i can merge my PR close action with my PR open action?
b
Yes, that should be fine. Under the hood the action will do different things based on the PR state
đź‘Ť 1
e.g. here you’ll see it only builds images for open PRs, a closed PR will skip this step and only update the state in the UI https://github.com/dagster-io/dagster-cloud-action/blob/main/actions/hybrid_branch_deploy/action.yml#L57
v
ah perfect! thanks @ben!
@ben all looks good, I was able to get it working! Thanks!
b
Fantastic! Glad to hear