Skip to content

Commit

Permalink
fix: added missing env for pr clean up workflow (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
aixaCode authored Aug 28, 2024
1 parent 34c7800 commit 4d35eac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr-closure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ jobs:
API_KEY: ${{ secrets.UNITY_CLOUD_API_KEY }}
ORG_ID: ${{ secrets.UNITY_CLOUD_ORG_ID }}
PROJECT_ID: ${{ secrets.UNITY_CLOUD_PROJECT_ID }}
TARGET: t_${{ matrix.target }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: python -u scripts/cloudbuild/build.py --delete
8 changes: 6 additions & 2 deletions scripts/cloudbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,14 @@ def get_any_running_builds(target, trueOnError = True):
sys.exit(1)

def delete_current_target():
response = requests.delete(f'{URL}/buildtargets/{os.getenv('TARGET')}', headers=HEADERS)

base_target_name = f'{re.sub(r'^t_', '', os.getenv('TARGET'))}-{re.sub('[^A-Za-z0-9]+', '-', os.getenv('BRANCH_NAME'))}'.lower()
response = requests.delete(f'{URL}/buildtargets/{base_target_name}', headers=HEADERS)

if response.status_code == 204:
print('Build target deleted successfully')
print(f'Build target deleted successfully: "{base_target_name}"')
elif response.status_code == 404:
print(f'Build target not found: "{base_target_name}"')
else:
print('Build target failed to be deleted with status code:', response.status_code)
print('Response body:', response.text)
Expand Down

0 comments on commit 4d35eac

Please sign in to comment.