-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into DEVOPS-XXX-use-new-docker-based-b2c-action
- Loading branch information
Showing
19 changed files
with
365 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
changelog: | ||
categories: | ||
- title: General Changes | ||
labels: | ||
- "*" | ||
exclude: | ||
authors: | ||
- dependabot | ||
- title: DevOps Changes | ||
labels: | ||
- devops | ||
exclude: | ||
labels: | ||
- dependencies | ||
- title: Dependencies | ||
labels: | ||
- dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Clear Azure Redis Cache | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
description: "Environment to clear caches for." | ||
resourceGroupName: | ||
default: "AMU_DevOps_RG" | ||
type: string | ||
description: "Name of Resource Group that the Azure Redis Instance is in." | ||
applicationCacheKey: | ||
default: "*" | ||
type: string | ||
description: "Cache key for the application" | ||
secrets: | ||
azureCredentials: | ||
required: true | ||
|
||
jobs: | ||
clear-redis-cache: | ||
name: Clear Azure Redis Cache | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to Azure | ||
uses: Andrews-McMeel-Universal/cache-azure-login@v1 | ||
with: | ||
azureCredentials: "${{ secrets.azureCredentials }}" | ||
|
||
- name: Install Dependencies | ||
uses: awalsh128/cache-apt-pkgs-action@v1 | ||
with: | ||
packages: redis-tools | ||
version: 1.0 | ||
|
||
# Script is adapted from https://github.com/Andrews-McMeel-Universal/azure-content-management_tool/blob/main/Scripts/rundeck/Flush-RedisCache.ps1 | ||
- name: Clear Redis Cache | ||
uses: azure/powershell@v1 | ||
with: | ||
inlineScript: | | ||
$CacheKey = "${{ inputs.applicationCacheKey }}" | ||
$ResourceGroupName = "${{ inputs.resourceGroupName }}" | ||
$Environment = "${{ inputs.environment }}" | ||
# Check to see if Azure Redis Cache PowerShell Module is installed | ||
Install-Module -Name Az.RedisCache -Confirm:$false | ||
# Get list of Redis instances using tags | ||
$Redis = Get-AzRedisCache -ResourceGroupName "$ResourceGroupName" | Where-Object { $_.Tag.Values -eq "$Environment" } | ||
# Loop through Redis instances | ||
$Redis | ForEach-Object { | ||
$RedisHostname = $_.HostName | ||
$RedisPort = $_.Port | ||
$RedisName = $_.Name | ||
$RedisKey = (Get-AzRedisCacheKey -Name $RedisName -ResourceGroupName $ResourceGroupName).PrimaryKey | ||
Write-Host "Authenticating to $RedisHostname..." -ForegroundColor DarkGray | ||
$RedisCommands = "AUTH $RedisKey | ||
SELECT 0 | ||
EVAL 'return redis.call(\'del\', unpack(redis.call(\'keys\', ARGV[1])))' 0 $CacheKey" | ||
Write-Host "Clearing cache key: $CacheKey" -ForegroundColor DarkGray | ||
$RedisResult = $RedisCommands | redis-cli -h $RedisHostname -p $RedisPort | ||
# Check if output from cache clearing command has correct status message | ||
if ($RedisResult -match '^\d+$') { | ||
Write-Host "Successfully flushed cache for $RedisHostname" -ForegroundColor Green | ||
} | ||
elseif ($RedisResult -match 'Wrong number of args calling Redis command From Lua script') { | ||
Write-Host "Cache key $CacheKey missing in $RedisHostname" -ForegroundColor Yellow | ||
} | ||
else { | ||
Write-Host "Cache key $CacheKey status unknown in $RedisHostname" -ForegroundColor Red | ||
Write-Host "Full output: $RedisResult" | ||
} | ||
} | ||
azPSVersion: "latest" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.