Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add purge job for bicep artifacts #8281

Merged
merged 12 commits into from
Jan 27, 2025
31 changes: 29 additions & 2 deletions .github/workflows/purge-azure-test-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,36 @@ jobs:
az group delete --resource-group $line --yes --verbose --no-wait
done

purge_bicep_types:
runs-on: ubuntu-latest
steps:
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.BICEPTYPES_CLIENT_ID }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need separate accounts for different operations? The other purge action uses AZURE_SP_TESTS_APPID. Wouldn't having one shared be better for actions that can be grouped together?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ACR is in a different account than the other Azure resources so we need different credentials to authenticate

tenant-id: ${{ secrets.BICEPTYPES_TENANT_ID }}
subscription-id: ${{ secrets.BICEPTYPES_SUBSCRIPTION_ID }}

# Delete Bicep types that are older than 90 days from the test registry
kachawla marked this conversation as resolved.
Show resolved Hide resolved
sk593 marked this conversation as resolved.
Show resolved Hide resolved
- name: Delete test bicep type manifests
run: |
REPO_NAME="test/radius"
REGISTRY_NAME="biceptypes"
DATE="$(date -d '90 days ago' +%Y-%m-%d)"

az acr manifest list-metadata \
-r $REGISTRY_NAME \
-n $REPO_NAME \
--query "[?lastUpdateTime<='$DATE'].digest" \
-o tsv | while read DIGEST; do
az acr manifest delete \
-n $REPO_NAME@$DIGEST \
-r $REGISTRY_NAME --yes
done

create_issue_on_failure:
name: Create issue for failing purge Azure test resources run
needs: [purge_azure_resources]
needs: [purge_azure_resources, purge_bicep_types]
runs-on: ubuntu-latest
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
steps:
Expand All @@ -106,4 +133,4 @@ jobs:
title: `Purge Azure test resources failed - Run ID: ${context.runId}`,
labels: ['bug', 'test-failure'],
body: `## Bug information \n\nThis bug is generated automatically if the purge Azure test resources workflow fails. For the further investigation, please visit [here](${process.env.ACTION_LINK}).`
})
})
Loading