From 0024d68bdeaa62dc671490c6353a93529e1da393 Mon Sep 17 00:00:00 2001 From: ytimocin Date: Fri, 10 May 2024 14:50:40 +0300 Subject: [PATCH] Update purget test resources to fix the workflow failures Signed-off-by: ytimocin --- .github/workflows/purge-test-resources.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/purge-test-resources.yaml b/.github/workflows/purge-test-resources.yaml index 58620ec2..3c0eb7ad 100644 --- a/.github/workflows/purge-test-resources.yaml +++ b/.github/workflows/purge-test-resources.yaml @@ -2,9 +2,15 @@ name: Purge test resources on: schedule: - cron: "30 0,12 * * *" + pull_request: + types: [opened, synchronize, reopened] + branches: + - v*.* + - edge env: AZURE_RG_DELETE_LIST_FILE: "az_rg_list.txt" VALID_RESOURCE_WINDOW: 6*60*60 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: purge_azure_resources: name: Azure resources clean-ups @@ -26,8 +32,9 @@ jobs: current_time=$(date +%s) hours_ago=$((current_time - ${{ env.VALID_RESOURCE_WINDOW }})) + echo "Hours ago: $hours_ago" - jq -r '.[] | select(.creationTime == null || .creationTime < '$hours_ago') | .Name' resource_groups.json > ${{ env.AZURE_RG_DELETE_LIST_FILE}} + jq -r '.[] | select(.creationTime == null or .creationTime < '$hours_ago') | .Name' resource_groups.json > ${{ env.AZURE_RG_DELETE_LIST_FILE}} jq -r '.[] | {name: .Name, creationTime: .creationTime // "None"}' resource_groups.json > $GITHUB_STEP_SUMMARY - name: Delete Azure Resource Groups @@ -40,8 +47,8 @@ jobs: done - name: Create GitHub issue on failure - if: ${{ failure() }} + if: failure() && github.event_name == 'schedule' run: | - gh issue create --title "Samples purge test resources failed \ + gh issue create --title "Samples purge test resources failed" \ --body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." \ - s--repo ${{ github.repository }} + --repo ${{ github.repository }}