π Update Rewards page content #1166
Workflow file for this run
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
name: PR - Delete Environment when PR is closed | |
on: | |
pull_request: | |
types: [closed] | |
workflow_dispatch: | |
inputs: | |
slotID: | |
description: "Pull request number" | |
required: true | |
default: "" | |
workflow_call: | |
inputs: | |
slotIDs: | |
type: string | |
description: "Slot IDs" | |
required: true | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
SLOT_NAME: ${{ inputs.slotIDs || inputs.slotID || github.event.number }} | |
SLOT_PREFIX: pr- | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
setting-up-slot-ids: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Converting slots into JSON Formatted Array | |
id: set-matrix | |
run: | | |
# TODO: Tech Debt - need to use it as JSON instead of space delimited - Github issue - https://github.com/SSWConsulting/SSW.Website/issues/1228 | |
$slotIDs = '${{ env.SLOT_NAME }}' -split ' ' | |
$slotIDsInJSonArray = ConvertTo-Json -Compress @($slotIDs) | |
echo "matrix=$slotIDsInJSonArray" >> $env:GITHUB_OUTPUT | |
delete-slot: | |
runs-on: ubuntu-latest | |
needs: setting-up-slot-ids | |
strategy: | |
matrix: | |
SLOT_NAME: ${{ fromJson(needs.setting-up-slot-ids.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Load .env file | |
uses: xom9ikk/dotenv@v2 | |
with: | |
path: ./.github | |
- name: Azure CLI - Login | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Cleanup ACR Pull & Key Vault permission | |
run: | | |
$acrId = az acr show ` | |
--resource-group ${{ env.AZURE_RESOURCE_GROUP }} ` | |
--name ${{ env.ACR_LOGIN_SERVER }} ` | |
--query id ` | |
--output tsv | |
Write-Host 'β acr found' | |
# get slot identity | |
$identityId = az webapp identity show ` | |
--resource-group ${{ env.AZURE_RESOURCE_GROUP }} ` | |
--name ${{ env.APP_SERVICE_NAME }} ` | |
--slot ${{ env.SLOT_PREFIX }}${{ matrix.SLOT_NAME }} ` | |
--query principalId ` | |
--output tsv | |
Write-Host 'β slot identity found' | |
# grant access to the identity on ACR | |
az role assignment delete ` | |
--assignee $identityId ` | |
--scope $acrId ` | |
--role acrpull ` | |
--output none | |
Write-Host 'β acrpull role deleted' | |
$kvId = az keyvault show ` | |
--resource-group ${{ env.AZURE_RESOURCE_GROUP }} ` | |
--name ${{ env.KEY_VAULT }} ` | |
--query id ` | |
--output tsv | |
if($kvId) { | |
Write-Host 'β KeyVault found' | |
# grant access to the identity on KeyVault | |
az role assignment delete ` | |
--assignee $identityId ` | |
--scope $kvId ` | |
--role "Key Vault Secrets User" ` | |
-o none | |
Write-Host 'β Key Vault Secrets User role deleted' | |
} else { | |
Write-Host 'β Key Vault not found' | |
} | |
- name: Delete slot on staging site | |
run: | | |
az webapp deployment slot delete ` | |
--resource-group ${{ env.AZURE_RESOURCE_GROUP }} ` | |
--name ${{ env.APP_SERVICE_NAME }} ` | |
--slot ${{ env.SLOT_PREFIX }}${{ matrix.SLOT_NAME }} ` | |
--output none |