Skip to content

Commit

Permalink
Rename to indicate support for more than Azure DevOps (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell authored Mar 8, 2024
1 parent 897a296 commit d787dca
Show file tree
Hide file tree
Showing 23 changed files with 231 additions and 209 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
IMAGE_NAME: 'azure-devops-cleaner'
IMAGE_NAME: 'azure-resources-cleaner'
DOCKER_BUILDKIT: 1 # Enable Docker BuildKit

steps:
Expand Down Expand Up @@ -62,9 +62,9 @@ jobs:
- name: Publish
run: |
dotnet publish \
${{ github.workspace }}/Tingle.AzdoCleaner/Tingle.AzdoCleaner.csproj \
${{ github.workspace }}/Tingle.AzureCleaner/Tingle.AzureCleaner.csproj \
-c Release \
-o ${{ github.workspace }}/drop/Tingle.AzdoCleaner
-o ${{ github.workspace }}/drop/Tingle.AzureCleaner
- name: Replace tokens
uses: cschleiden/replace-tokens@v1
Expand Down Expand Up @@ -109,11 +109,12 @@ jobs:

- name: Pull Docker base image & warm Docker cache
run: docker pull "ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest"
continue-on-error: true

- name: Build image
run: |
docker build \
-f Tingle.AzdoCleaner/Dockerfile \
-f Tingle.AzureCleaner/Dockerfile \
--label com.github.image.run.id=${{ github.run_id }} \
--label com.github.image.run.number=${{ github.run_number }} \
--label com.github.image.job.id=${{ github.job }} \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Delete old packages
uses: actions/delete-package-versions@v5
with:
package-name: 'azure-devops-cleaner'
package-name: 'azure-resources-cleaner'
package-type: 'container'
min-versions-to-keep: 20
delete-only-pre-release-versions: "true"
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Azure DevOps Cleaner

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/tinglesoftware/azure-devops-cleaner/build.yml?branch=main&style=flat-square)
[![Release](https://img.shields.io/github/release/tinglesoftware/azure-devops-cleaner.svg?style=flat-square)](https://github.com/tinglesoftware/azure-devops-cleaner/releases/latest)
[![license](https://img.shields.io/github/license/tinglesoftware/azure-devops-cleaner.svg?style=flat-square)](LICENSE)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/tinglesoftware/azure-resources-cleaner/build.yml?branch=main&style=flat-square)
[![Release](https://img.shields.io/github/release/tinglesoftware/azure-resources-cleaner.svg?style=flat-square)](https://github.com/tinglesoftware/azure-resources-cleaner/releases/latest)
[![license](https://img.shields.io/github/license/tinglesoftware/azure-resources-cleaner.svg?style=flat-square)](LICENSE)

This repository houses a convenience tool for cleaning up resources based on the terminal status of pull requests in Azure DevOps. This is particularly useful in removing the reviewApp resources in environments, that created automatically by Azure Pipelines. In addition, it will also cleanup resources deployed to Azure.

Expand All @@ -23,9 +23,9 @@ This repository houses a convenience tool for cleaning up resources based on the

### Deployment to Azure

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Ftinglesoftware%2Fazure-devops-cleaner%2Fmain%2Fmain.json)
[![Deploy to Azure US Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Ftinglesoftware%2Fazure-devops-cleaner%2Fmain%2Fmain.json)
[![Visualize](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.svg?sanitize=true)](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Ftinglesoftware%2Fazure-devops-cleaner%2Fmain%2Fmain.json)
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Ftinglesoftware%2Fazure-resources-cleaner%2Fmain%2Fmain.json)
[![Deploy to Azure US Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Ftinglesoftware%2Fazure-resources-cleaner%2Fmain%2Fmain.json)
[![Visualize](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.svg?sanitize=true)](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Ftinglesoftware%2Fazure-resources-cleaner%2Fmain%2Fmain.json)

The easiest means of deployment is to use the relevant button above. You can also use the [main.json](/main.json) or [main.bicep](/main.bicep) files. You will need an Azure subscription and a resource group to deploy to any of the Azure hosts.

Expand All @@ -35,7 +35,7 @@ The easiest means of deployment is to use the relevant button above. You can als
|azureDevOpsProjectUrl|The URL of the Azure DevOps project or collection. For example `https://dev.azure.com/fabrikam/DefaultCollection`. This URL must be accessible from the network that the deployment is done in. You can modify the deployment to be done in an private network but you are on your own there.|Yes|**none**|
|azureDevOpsProjectToken|Personal Access Token (PAT) for accessing the Azure DevOps project. It must have `Environment (Read & Manage)` permissions.|Yes|**none**|
|location|Location to deploy the resources.|No|<resource-group-location>|
|name|The name of all resources.|No|`azdo-cleaner`|
|name|The name of all resources.|No|`azure-cleaner`|
|dockerImageTag|The image tag to use when pulling the docker container. A tag also defines the version. You should avoid using `latest`. Example: `0.1.0`|No|<version-downloaded>|

> The template includes a User Assigned Managed Identity, which is used when performing Azure Resource Manager operations such as deletions. After deployment, you should assign `Contributor` permissions to it where you want it to operate such as a subscription or a resource group. See [official docs](https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal-managed-identity#user-assigned-managed-identity) for how to assign permissions.<br/><br/> You can also do the role assignment on a management group. The tool scans for subscriptions that it has access to before listing the resources of a given type so you need not change anything in the deployment after altering permissions.
Expand Down Expand Up @@ -63,7 +63,7 @@ If you use the [REST API](https://learn.microsoft.com/en-us/rest/api/azure/devop
"consumerActionId": "httpRequest",
"publisherInputs": {
"notificationType": "StatusUpdateNotification",
"projectId": "<identifier-of-azdo-project>"
"projectId": "<identifier-of-azure-project>"
},
"consumerInputs": {
"detailedMessagesToSend": "none",
Expand All @@ -75,7 +75,7 @@ If you use the [REST API](https://learn.microsoft.com/en-us/rest/api/azure/devop
}
```

> When using Azure Container Apps, the url should have the format:<br/>`https://azdo-cleaner.{envrionment-unique-dentifier}.{region}.azurecontainerapps.io/webhooks/azure`<br/>For example: `https://azdo-cleaner.blackplant-123456a7.westeurope.azurecontainerapps.io/webhooks/azure`
> When using Azure Container Apps, the url should have the format:<br/>`https://azure-cleaner.{envrionment-unique-dentifier}.{region}.azurecontainerapps.io/webhooks/azure`<br/>For example: `https://azure-cleaner.blackplant-123456a7.westeurope.azurecontainerapps.io/webhooks/azure`
## What is supported?

Expand All @@ -87,7 +87,7 @@ This tool looks for resources or sub-resources named in a number of formats:
- `ra-{pull-request-identifier}`
- `ra{pull-request-identifier}`

For example: `ra-2215`, `ra2215`, and `review-app-2215` will all be handled. Make sure you name your preview environments accordingly. If you wish to contribute more reasonable patterns, check [here](https://github.com/tinglesoftware/azure-devops-cleaner/blob/7e21f338f78f6af634d8aa35d39542455c55415b/Tingle.AzdoCleaner/AzdoEventHandler.cs#L100)
For example: `ra-2215`, `ra2215`, and `review-app-2215` will all be handled. Make sure you name your preview environments accordingly. If you wish to contribute more reasonable patterns, check [here](https://github.com/tinglesoftware/azure-resources-cleaner/blob/7e21f338f78f6af634d8aa35d39542455c55415b/Tingle.AzureCleaner/AzureCleaner.cs#L100)

### Preview environments on Azure DevOps

Expand Down
123 changes: 0 additions & 123 deletions Tingle.AzdoCleaner.Tests/AzdoEventHandlerTests.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Tingle.AzdoCleaner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AzdoCleaner", "Tingle.AzdoCleaner\Tingle.AzdoCleaner.csproj", "{F3BDB109-999B-4F3C-A6C5-745CC5BE4B68}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AzureCleaner", "Tingle.AzureCleaner\Tingle.AzureCleaner.csproj", "{F3BDB109-999B-4F3C-A6C5-745CC5BE4B68}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AzdoCleaner.Tests", "Tingle.AzdoCleaner.Tests\Tingle.AzdoCleaner.Tests.csproj", "{BCDFC1A1-1FF4-4F26-9DEC-676CEC1418BF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AzureCleaner.Tests", "Tingle.AzureCleaner.Tests\Tingle.AzureCleaner.Tests.csproj", "{BCDFC1A1-1FF4-4F26-9DEC-676CEC1418BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Xunit;

namespace Tingle.AzdoCleaner.Tests;
namespace Tingle.AzureCleaner.Tests;

public class AzdoProjectUrlTests
{
Expand Down
Loading

0 comments on commit d787dca

Please sign in to comment.