Skip to content

Commit 704b051

Browse files
committed
Add support for Front Door in Purge CDN workflow
1 parent d9324dd commit 704b051

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

.github/workflows/purge-cdn.yaml

+27-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ on:
1919
required: false
2020
type: string
2121
description: "CDN Endpoint."
22+
resourceType:
23+
required: false
24+
type: string
25+
description: "Resource Type. Can be either 'frontdoor' or 'cdn'."
26+
default: 'cdn'
2227
secrets:
2328
azureCredentials:
2429
required: true
@@ -41,19 +46,34 @@ jobs:
4146
Write-Error "CDN Resource Group is required. Please provide the CDN Resource Group name when calling the workflow."
4247
exit 1
4348
}
49+
else {
50+
$ResourceGroup="${{ inputs.cdnResourceGroup }}"
51+
}
4452
4553
if (-not ${{ inputs.cdnProfile }}) {
4654
Write-Error "CDN Profile is required. Please provide the CDN Profile name when calling the workflow."
4755
exit 1
4856
}
57+
else {
58+
$ProfileName="${{ inputs.cdnProfile }}"
59+
}
4960
5061
if (-not ${{ inputs.cdnEndpoint }}) {
51-
Write-Error "CDN Endpoint is required. Please provide the CDN Endpoint name when calling the workflow."
52-
exit 1
62+
if ("${{ github.event.repository.name }}" -match "*_game") {
63+
$EndpointName = (az afd endpoint list --profile-name "$ProfileName" --resource-group "$ResourceGroup" --query "[?tags.\"repository-name\" == '${{ github.event.repository.name }}'].name" -o tsv)
64+
}
65+
else {
66+
Write-Error "CDN Endpoint is required. Please provide the CDN Endpoint name when calling the workflow."
67+
exit 1
68+
}
69+
}
70+
else {
71+
$EndpointName="${{ inputs.cdnEndpoint }}"
5372
}
5473
55-
$ResourceGroup = "${{ inputs.cdnResourceGroup }}"
56-
$ProfileName = "${{ inputs.cdnProfile }}"
57-
$EndpointName = "${{ inputs.cdnEndpoint }}"
58-
59-
Clear-AzCdnEndpointContent -EndpointName $EndpointName -ProfileName $ProfileName -ResourceGroupName $ResourceGroup -ContentPath '/*'
74+
if (${{ inputs.resourceType }} -eq 'frontdoor') {
75+
Clear-AzFrontDoorEndpointContent -EndpointName $EndpointName -ProfileName $ProfileName -ResourceGroupName $ResourceGroup -ContentPaths '/*'
76+
}
77+
else {
78+
Clear-AzCdnEndpointContent -EndpointName $EndpointName -ProfileName $ProfileName -ResourceGroupName $ResourceGroup -ContentPath '/*'
79+
}

0 commit comments

Comments
 (0)