From c155a90fe446d8d5e85c6aa6fda5f056b142e8d1 Mon Sep 17 00:00:00 2001 From: Shruthi Kumar Date: Mon, 27 Jan 2025 12:15:02 -0800 Subject: [PATCH] Add purge job for bicep artifacts (#8281) # Description This adds a purge job for test bicep artifacts. It will delete any manifests that are older than 90 days. This only applies to the test schemas uploaded as part of PRs, not any major release versions of Radius or AWS bicep types. A successful test run can be found here: https://github.com/radius-project/radius/actions/runs/12939411131 ## Type of change - This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional). Fixes: #issue_number ## Contributor checklist Please verify that the PR meets the following requirements, where applicable: - [ ] An overview of proposed schema changes is included in a linked GitHub issue. - [ ] A design document PR is created in the [design-notes repository](https://github.com/radius-project/design-notes/), if new APIs are being introduced. - [ ] If applicable, design document has been reviewed and approved by Radius maintainers/approvers. - [ ] A PR for the [samples repository](https://github.com/radius-project/samples) is created, if existing samples are affected by the changes in this PR. - [ ] A PR for the [documentation repository](https://github.com/radius-project/docs) is created, if the changes in this PR affect the documentation or any user facing updates are made. - [ ] A PR for the [recipes repository](https://github.com/radius-project/recipes) is created, if existing recipes are affected by the changes in this PR. --------- Signed-off-by: sk593 --- .../workflows/purge-azure-test-resources.yaml | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/purge-azure-test-resources.yaml b/.github/workflows/purge-azure-test-resources.yaml index 43159aa0a6..5c6ac2ff51 100644 --- a/.github/workflows/purge-azure-test-resources.yaml +++ b/.github/workflows/purge-azure-test-resources.yaml @@ -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 }} + tenant-id: ${{ secrets.BICEPTYPES_TENANT_ID }} + subscription-id: ${{ secrets.BICEPTYPES_SUBSCRIPTION_ID }} + + # Delete Bicep types that are older than 30 days from the test registry + - name: Delete test bicep type manifests + run: | + REPO_NAME="test/radius" + REGISTRY_NAME="biceptypes" + DATE="$(date -d '30 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: @@ -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}).` - }) + }) \ No newline at end of file