Skip to content

Commit

Permalink
[ci] move cleanup to azure tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgorana committed Feb 9, 2024
1 parent e934baa commit 9e8ed3c
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions .github/workflows/cd-syft-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v3

- name: Install Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az version
# - name: Install Azure CLI
# run: |
# curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# az version

- name: Login to Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_GITHUB_CI }}
# - name: Login to Azure CLI
# uses: azure/login@v1
# with:
# creds: ${{ secrets.AZURE_CREDENTIALS_GITHUB_CI }}

- name: Login to Azure Container Registry
uses: azure/docker-login@v1
Expand Down Expand Up @@ -179,35 +179,35 @@ jobs:
push: "origin main"
cwd: "./infrastructure/"

- name: Cleanup Azure Container Registry
run: |
ACR_REGISTRY_NAME=${{ secrets.ACR_REGISTRY_NAME }}
echo ">> Fetching repo list.."
REPO_LIST=$(az acr repository list -n $ACR_REGISTRY_NAME -o tsv)
KEEP_PREV_VERSIONS=5
TAIL_FROM_LINE=$(($KEEP_PREV_VERSIONS + 1))
for repo in $REPO_LIST
do
echo "Cleaning up '$repo'"
# remove dev tags
az acr repository show-tags --name $ACR_REGISTRY_NAME --repository $repo --orderby time_desc --output tsv \
| grep dev- \
| tail -n +$TAIL_FROM_LINE \
| xargs -r -I% az acr repository untag --name $ACR_REGISTRY_NAME --image $repo:%
# remove beta tags
az acr repository show-tags --name $ACR_REGISTRY_NAME --repository $repo --orderby time_desc --output tsv \
| grep beta \
| tail -n +$TAIL_FROM_LINE \
| xargs -r -I% az acr repository untag --name $ACR_REGISTRY_NAME --image $repo:%
done
- name: Logout and cleanup Azure account
if: always()
run: |
az logout
az cache purge
az account clear
# - name: Cleanup Azure Container Registry
# run: |
# ACR_REGISTRY_NAME=${{ secrets.ACR_REGISTRY_NAME }}

# echo ">> Fetching repo list.."
# REPO_LIST=$(az acr repository list -n $ACR_REGISTRY_NAME -o tsv)

# KEEP_PREV_VERSIONS=5
# TAIL_FROM_LINE=$(($KEEP_PREV_VERSIONS + 1))

# for repo in $REPO_LIST
# do
# echo "Cleaning up '$repo'"
# # remove dev tags
# az acr repository show-tags --name $ACR_REGISTRY_NAME --repository $repo --orderby time_desc --output tsv \
# | grep dev- \
# | tail -n +$TAIL_FROM_LINE \
# | xargs -r -I% az acr repository untag --name $ACR_REGISTRY_NAME --image $repo:%

# # remove beta tags
# az acr repository show-tags --name $ACR_REGISTRY_NAME --repository $repo --orderby time_desc --output tsv \
# | grep beta \
# | tail -n +$TAIL_FROM_LINE \
# | xargs -r -I% az acr repository untag --name $ACR_REGISTRY_NAME --image $repo:%
# done

# - name: Logout and cleanup Azure account
# if: always()
# run: |
# az logout
# az cache purge
# az account clear

0 comments on commit 9e8ed3c

Please sign in to comment.