Azure / Azure/static-web-apps

GitHub Action sometimes does not clean up the environment

Open
#873 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Configure GitHub Static Apps with included workflow
1. Create a PR to `integration` branch
1. Merge the PR into `integration` branch
1. Look for the environment in Static Web Apps.

**Expected behavior**
The environment is always cleaned up after its PR is closed.

**Observed behavior**
Inconsistently, the Action runs with seemingly successful output (see below), but the PR branch environment remains in Static Apps.

**Screenshots**
N/A

**Device info (if applicable):**
N/A

**Additional context**
I don't recall observing this behavior prior to using environment branches.

Failure to cleanup environments causes us to hit our limit on environments (10), which causes Static Web App deployments to fail, which causes more PRs to queue up, which exacerbates the problem and takes much time to resolve on a frequent basis (between weekly to daily).

**workflow config**
```
name: Storybook CI/CD

on:
push:
branches:
- integration
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- integration

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
outputs:
url: ${{ steps.builddeploy.outputs.static_web_app_url }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web-client/package-lock.json
registry-url: https://npm.pkg.github.com
- name: Login to NPM
run: echo "//npm.pkg.github.com/:_authToken=$NPM_TOKEN" >> .npmrc
env:
NPM_TOKEN: ${{ secrets.READ_PAT }}
- name: Install dependencies
shell: bash
run: |
cd web-client
npm ci
- name: Build
shell: bash
run: |
cd web-client
npm run build-storybook
cp staticwebapp.storybook.config.json storybook-static/staticwebapp.storybook.config.json
env:
NODE_OPTIONS: "--max_old_space_size=4096"
# TODO: https://docs.microsoft.com/en-us/azure/static-web-apps/build-configuration?tabs=github-actions#monorepo-support
- name: Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.WEB_CLIENT_STORYBOOK_DEPLOYMENT_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
skip_app_build: true
app_location: "/web-client/storybook-static"
production_branch: integration
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.WEB_CLIENT_STORYBOOK_DEPLOYMENT_TOKEN }}
action: "close"
```

**Output from the cleanup GitHub Action**
```
/usr/bin/docker run --name cd98f85f4fb1b5a3747cb950c13e166a55cb8_950b85 --label 4cd98f --workdir /github/workspace --rm -e INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN -e INPUT_ACTION -e INPUT_APP_LOCATION -e INPUT_API_BUILD_COMMAND -e INPUT_API_LOCATION -e INPUT_APP_ARTIFACT_LOCATION -e INPUT_OUTPUT_LOCATION -e INPUT_APP_BUILD_COMMAND -e INPUT_REPO_TOKEN -e INPUT_ROUTES_LOCATION -e INPUT_SKIP_APP_BUILD -e INPUT_CONFIG_FILE_LOCATION -e INPUT_SKIP_API_BUILD -e INPUT_PRODUCTION_BRANCH -e INPUT_DEPLOYMENT_ENVIRONMENT -e INPUT_IS_STATIC_EXPORT -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/monorepo/monorepo":"/github/workspace" 4cd98f:85f4fb1b5a3747cb950c13e166a55cb8
DeploymentId: f9[6](https://github.com/*****/*****/runs/7665220681?check_suite_focus=true#step:3:7)61ffa-[7](https://github.com/*****/*****/runs/7665220681?check_suite_focus=true#step:3:8)55a-413e-[8](https://github.com/*****/*****/runs/7665220681?check_suite_focus=true#step:3:9)e96-79aa6b403b2a

Looking for event info
Thanks for using Azure Static Web Apps!
Exiting
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.