Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
02542c1
Merge pull request #3 from Azure/main
AlexanderSehr Feb 10, 2022
b8483d7
Merge pull request #5 from Azure/main
AlexanderSehr Apr 12, 2022
54a1bf2
Merge branch 'main' of https://github.com/MrMCake/ResourceModules
AlexanderSehr Apr 12, 2022
39511c3
Added forms
AlexanderSehr Apr 12, 2022
2d7616b
Update issue templates
AlexanderSehr Apr 12, 2022
c193bb3
Re-apply
AlexanderSehr Apr 12, 2022
e5709c7
Update issue templates
AlexanderSehr Apr 12, 2022
3ff3629
Update to latest
AlexanderSehr Apr 12, 2022
4fdbb63
Update to latest
AlexanderSehr Apr 12, 2022
499672f
Updated forms
AlexanderSehr Apr 12, 2022
8b5228b
Updated templates
AlexanderSehr Apr 12, 2022
175d492
Updated templates
AlexanderSehr Apr 12, 2022
c54a11e
Update .github/ISSUE_TEMPLATE/bug_report.yml
AlexanderSehr Apr 13, 2022
a517f66
Update .github/PULL_REQUEST_TEMPLATE.md
AlexanderSehr Apr 13, 2022
6b41e83
Merge branch 'Azure:main' into main
AlexanderSehr May 13, 2022
50a2018
Update to latest
AlexanderSehr May 13, 2022
c5449be
Update to latest
AlexanderSehr May 13, 2022
4a39f41
Merge pull request #8 from MrMCake/users/alsehr/maintenanceWorkflows
AlexanderSehr May 13, 2022
d9cc96f
Merge branch 'Azure:main' into main
AlexanderSehr May 31, 2022
2061048
Added pipeline to auto-assign issues
AlexanderSehr May 31, 2022
3f077f3
Update platform.issueAssignment.yml
AlexanderSehr May 31, 2022
4690418
Update platform.issueAssignment.yml
AlexanderSehr May 31, 2022
e56b1a5
Update platform.issueAssignment.yml
AlexanderSehr May 31, 2022
89aad7c
Delete platform.bug.yml
AlexanderSehr May 31, 2022
dd2b3ec
Delete platform.issueAssignment.yml
AlexanderSehr May 31, 2022
70eadfb
Merge branch 'Azure:main' into main
AlexanderSehr Jun 27, 2022
de4471f
Merge branch 'Azure:main' into main
AlexanderSehr Aug 3, 2022
45bf842
Merge branch 'Azure:main' into main
AlexanderSehr Aug 5, 2022
072f03b
Merge branch 'Azure:main' into main
AlexanderSehr Sep 19, 2022
c1a51b1
Merge branch 'Azure:main' into main
AlexanderSehr Nov 11, 2022
56192af
Added cleanup pipeline IP
AlexanderSehr Nov 11, 2022
c05148a
Moved setting to runtime parameter
AlexanderSehr Nov 18, 2022
de7cb68
Update to latest
AlexanderSehr Nov 18, 2022
c2f8857
Update to latest
AlexanderSehr Nov 18, 2022
319b339
Adjusted output handling
AlexanderSehr Nov 18, 2022
e7d74b4
Update to latest
AlexanderSehr Nov 18, 2022
2dd480e
Update to latest
AlexanderSehr Nov 18, 2022
319393f
Updated Analysis services to different pipeline syntax
AlexanderSehr Nov 18, 2022
da5ca8a
Additional FromJSON
AlexanderSehr Nov 18, 2022
55e8c19
rollback on test file paths
AlexanderSehr Nov 18, 2022
f5ef037
Updated pipelines
AlexanderSehr Nov 18, 2022
495bdd7
Update .azuredevops/platformPipelines/platform.deployment.removal.yml
AlexanderSehr Nov 26, 2022
8bc5ef5
Updated desc
AlexanderSehr Nov 26, 2022
af10ffb
Added ref
AlexanderSehr Nov 26, 2022
f4d1d0e
Update to latest
AlexanderSehr Nov 26, 2022
9295d37
Update to latest
AlexanderSehr Nov 26, 2022
fa59fb1
Added example
AlexanderSehr Nov 26, 2022
3174c6e
Update to latest
AlexanderSehr Nov 26, 2022
d478067
Update to latest
AlexanderSehr Nov 26, 2022
7a47631
Update to latest
AlexanderSehr Nov 26, 2022
93ea332
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr Nov 28, 2022
c11c349
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr Nov 28, 2022
c95aacf
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr Nov 28, 2022
2023b81
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr Nov 28, 2022
e811f2e
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr Nov 28, 2022
2558e6e
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr Nov 28, 2022
ea0ef59
Update docs/wiki/The CI environment.md
AlexanderSehr Nov 28, 2022
5646dd1
Update .github/actions/templates/getWorkflowInput/action.yml
AlexanderSehr Nov 28, 2022
26ba983
Update utilities/pipelines/deploymentRemoval/Clear-SubscriptionDeploy…
AlexanderSehr Nov 28, 2022
de610e7
Update utilities/pipelines/deploymentRemoval/Clear-ManagementGroupDep…
AlexanderSehr Nov 28, 2022
5ed1be7
Renamed file
AlexanderSehr Nov 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .azuredevops/platformPipelines/platform.deployment.removal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: '.Platform - Remove Deployments'

parameters:
- name: handleSubscriptionScope
displayName: Include Subscription deployments
type: boolean
default: true # Note: This requires your service principal to have permissions on the subscription scope.
- name: handleManagementGroupScope
displayName: Include Management Group deployments
type: boolean
default: true # Note: This requires your service principal to have permissions on the management group scope.
- name: maxDeploymentRetentionInDays
displayName: The number of days to keep deployments with status [running] or [failed]
type: number
default: 14

schedules:
- cron: "0 0 * * *"
displayName: Nightly run
branches:
include:
- main

pr: none

variables:
- template: '../../settings.yml'
- group: 'PLATFORM_VARIABLES'

jobs:
- job: Remove_Subscription_Deployments
condition: and(succeeded(), eq('${{ parameters.handleSubscriptionScope }}', 'true'))
displayName: Remove Subscription deployments
pool:
${{ if eq(variables['vmImage'], '') }}:
name: $(poolName)
${{ if eq(variables['poolName'], '') }}:
vmImage: $(vmImage)
steps:
- checkout: self
- task: PowerShell@2
displayName: 'Setup agent for deployment'
inputs:
targetType: inline
pwsh: true
script: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1')

# Define PS modules to install on the runner
$Modules = @(
@{ Name = 'Az.Accounts' }
)

# Set agent up
Set-EnvironmentOnAgent -PSModules $Modules
- task: AzurePowerShell@5
displayName: 'Cleanup deployments via connection [$(serviceConnection)]'
inputs:
azureSubscription: '$(serviceConnection)'
azurePowerShellVersion: 'latestVersion'
preferredAzurePowerShellVersion: ''
pwsh: true
ScriptType: InlineScript
inline: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'deploymentRemoval' 'Clear-SubscriptionDeployment.ps1')

$functionInput = @{
SubscriptionId = '$(ARM_SUBSCRIPTION_ID)'
maxDeploymentRetentionInDays = ${{ parameters.maxDeploymentRetentionInDays }}
}

Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Clear-SubscriptionDeployment @functionInput

- job: Remove_ManagementGroup_Deployments
condition: and(succeeded(), eq('${{ parameters.handleManagementGroupScope }}', 'true'))
displayName: Remove Management Group deployments
pool:
${{ if eq(variables['vmImage'], '') }}:
name: $(poolName)
${{ if eq(variables['poolName'], '') }}:
vmImage: $(vmImage)
steps:
- checkout: self
- task: PowerShell@2
displayName: 'Setup agent for deployment'
inputs:
targetType: inline
pwsh: true
script: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1')

# Define PS modules to install on the runner
$Modules = @(
@{ Name = 'Az.Accounts' }
)

# Set agent up
Set-EnvironmentOnAgent -PSModules $Modules
- task: AzurePowerShell@5
displayName: 'Cleanup deployments via connection [$(serviceConnection)]'
inputs:
azureSubscription: '$(serviceConnection)'
azurePowerShellVersion: 'latestVersion'
preferredAzurePowerShellVersion: ''
pwsh: true
ScriptType: InlineScript
inline: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'deploymentRemoval' 'Clear-ManagementGroupDeployment.ps1')

$functionInput = @{
ManagementGroupId = '$(ARM_MGMTGROUP_ID)'
maxDeploymentRetentionInDays = ${{ parameters.maxDeploymentRetentionInDays }}
}

Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Clear-ManagementGroupDeployment @functionInput
39 changes: 25 additions & 14 deletions .github/actions/templates/getWorkflowInput/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
## ACTION OUTPUTS ##
##----------------------------------------##
##
## |==================================================================================================================|
## | Output | Description |
## |------------------|-----------------------------------------------------------------------------------------------|
## | removeDeployment | A flag, set in the pipeline, to control whether deployment resources should be removed or not |
## |==================================================================================================================|
## |==========================================================================================|
## | Output | Description |
## |---------------|--------------------------------------------------------------------------|
## | workflowInput | A table of all pipeline input parameters and their value in JSON format. |
## |==========================================================================================|
##
##---------------------------------------------##

Expand All @@ -44,9 +44,9 @@ inputs:
required: true

outputs:
removeDeployment:
description: 'A flag, set in the pipeline, to control whether deployment resources should be removed or not'
value: ${{ steps.get-input-param-action.outputs.removeDeployment }}
workflowInput:
description: 'A table of all pipeline input parameters and their value in JSON format.'
value: ${{ steps.get-input-param-action.outputs.workflowInput }}

runs:
using: 'composite'
Expand All @@ -61,7 +61,15 @@ runs:

# When running from workflow_dispatch event get input values
if ('${{ github.event_name }}' -eq 'workflow_dispatch') {
$removeDeployment='${{ github.event.inputs.removeDeployment }}'
$parameters = '${{ toJSON(github.event.inputs) }}' | ConvertFrom-Json -AsHashTable

# Output values to be accessed by next jobs
$workflowInput = @{}
foreach($parameterName in $parameters.Keys) {
Write-Verbose ('Passing output [{0}] with value [{1}]' -f $parameterName, $parameters[$parameterName]) -Verbose
$workflowInput[$parameterName] = $parameters[$parameterName]
}
Write-Output ('{0}={1}' -f 'workflowInput', ($workflowInput | ConvertTo-Json -Compress)) >> $env:GITHUB_OUTPUT
}
# Otherwise retrieve default values
else {
Expand All @@ -76,11 +84,14 @@ runs:
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

$workflowParameters = Get-GitHubWorkflowDefaultInput @functionInput -Verbose
$removeDeployment = $workflowParameters.removeDeployment
}

# Output values to be accessed by next jobs
Write-Output ('{0}={1}' -f 'removeDeployment', $removeDeployment) >> $env:GITHUB_OUTPUT

# Output values to be accessed by next jobs
$workflowInput = @{}
foreach($parameterName in $workflowParameters.Keys) {
Write-Verbose ('Passing output [{0}] with value [{1}]' -f $parameterName, $workflowParameters[$parameterName]) -Verbose
$workflowInput[$parameterName] = $workflowParameters[$parameterName]
}
Write-Output ('{0}={1}' -f 'workflowInput', ($workflowInput | ConvertTo-Json -Compress)) >> $env:GITHUB_OUTPUT
}
Write-Output '::endgroup::'
shell: pwsh
6 changes: 3 additions & 3 deletions .github/workflows/ms.aad.domainservices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -112,7 +112,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ms.analysisservices.servers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -111,7 +111,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ms.apimanagement.service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -111,7 +111,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -111,7 +111,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ms.authorization.locks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -114,7 +114,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ms.authorization.policyassignments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -114,7 +114,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ms.authorization.policydefinitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}

#########################
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
moduleTestFilePaths: ${{ fromJson(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand All @@ -114,7 +114,7 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'
removeDeployment: '${{ (fromJson(needs.job_initialize_pipeline.outputs.workflowInput)).removeDeployment }}'

##################
# Publishing #
Expand Down
Loading