Static-Web-App fails to clean environment when PR is closed quickly after a push.
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The github action does not check if the PR is still open before it deploys a new environment. Deployment is done even though the "Closed PR" action is finished, and the environment should be closed. This leaves dangling environments in the Azure Static Web App portal, which admins need to clean up regularly.

**To Reproduce**
Steps to reproduce the behavior:
1. Open a PR with your change,
2. Do NOT wait for the CI steps to finish.
3. Quickly merge the change the PR
4. A few minutes later the "Azure Static Web App" github action finished.
5. Observe that this environment stays open in the Azure Static Web App portal in the Environments list
6. Manually clean this environment, as the PR is already merged so the cleanup step will never run.
**Expected behavior**
The cleanup should await the ongoing job, or cancel the ongoing deployment before removing the environment.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the race between the PR-close cleanup and the Azure Static Web App deployment described in the issue. Trace the GitHub Action behavior for a deployment that is still running when a PR is merged or closed. Done means the ongoing deployment is awaited or cancelled and no dangling environment remains in the Azure Static Web App portal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, github-actions
- Domain
- ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100