Skip to content

Commit

Permalink
Add support for Front Door in Purge CDN workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ebronson68 committed Jan 24, 2025
1 parent d9324dd commit 704b051
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/purge-cdn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ on:
required: false
type: string
description: "CDN Endpoint."
resourceType:
required: false
type: string
description: "Resource Type. Can be either 'frontdoor' or 'cdn'."
default: 'cdn'
secrets:
azureCredentials:
required: true
Expand All @@ -41,19 +46,34 @@ jobs:
Write-Error "CDN Resource Group is required. Please provide the CDN Resource Group name when calling the workflow."
exit 1
}
else {
$ResourceGroup="${{ inputs.cdnResourceGroup }}"
}
if (-not ${{ inputs.cdnProfile }}) {
Write-Error "CDN Profile is required. Please provide the CDN Profile name when calling the workflow."
exit 1
}
else {
$ProfileName="${{ inputs.cdnProfile }}"
}
if (-not ${{ inputs.cdnEndpoint }}) {
Write-Error "CDN Endpoint is required. Please provide the CDN Endpoint name when calling the workflow."
exit 1
if ("${{ github.event.repository.name }}" -match "*_game") {
$EndpointName = (az afd endpoint list --profile-name "$ProfileName" --resource-group "$ResourceGroup" --query "[?tags.\"repository-name\" == '${{ github.event.repository.name }}'].name" -o tsv)
}
else {
Write-Error "CDN Endpoint is required. Please provide the CDN Endpoint name when calling the workflow."
exit 1
}
}
else {
$EndpointName="${{ inputs.cdnEndpoint }}"
}
$ResourceGroup = "${{ inputs.cdnResourceGroup }}"
$ProfileName = "${{ inputs.cdnProfile }}"
$EndpointName = "${{ inputs.cdnEndpoint }}"
Clear-AzCdnEndpointContent -EndpointName $EndpointName -ProfileName $ProfileName -ResourceGroupName $ResourceGroup -ContentPath '/*'
if (${{ inputs.resourceType }} -eq 'frontdoor') {
Clear-AzFrontDoorEndpointContent -EndpointName $EndpointName -ProfileName $ProfileName -ResourceGroupName $ResourceGroup -ContentPaths '/*'
}
else {
Clear-AzCdnEndpointContent -EndpointName $EndpointName -ProfileName $ProfileName -ResourceGroupName $ResourceGroup -ContentPath '/*'
}

0 comments on commit 704b051

Please sign in to comment.