Skip to content

Commit

Permalink
Update purget test resources to fix the workflow failures
Browse files Browse the repository at this point in the history
Signed-off-by: ytimocin <[email protected]>
  • Loading branch information
ytimocin committed May 10, 2024
1 parent bc43e42 commit 9ba20f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/purge-test-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
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
Expand All @@ -22,13 +23,13 @@ jobs:
- name: List Test Resource Groups
run: |
echo "## Test resource group list" >> $GITHUB_STEP_SUMMARY
az group list --query "[?starts_with(name, 'samplestest-')].{Name:name, creationTime:tags.creationTime}" -o json > resource_groups.json
az group list --query "[?starts_with(name, 'rg-samplestest-')].{Name:name, creationTime:tags.creationTime}" -o json > resource_groups.json
current_time=$(date +%s)
hours_ago=$((current_time - ${{ env.VALID_RESOURCE_WINDOW }}))
jq -r '.[] | select(.creationTime == null || .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
jq -r '.[] | select(.creationTime == null // (.creationTime | tonumber) < '$hours_ago') | .Name' resource_groups.json > ${{ env.AZURE_RG_DELETE_LIST_FILE}}
jq -r '.[] | "\(.Name) \(.creationTime // "None")"' resource_groups.json > $GITHUB_STEP_SUMMARY
- name: Delete Azure Resource Groups
run: |
Expand All @@ -40,8 +41,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 }}

0 comments on commit 9ba20f7

Please sign in to comment.