Skip to content

Commit

Permalink
Task 97679: Zappie deployment is failing (#66)
Browse files Browse the repository at this point in the history
* Fixing Azure login and removed Manual deployment

* Replace Azure login method

* fixed web.redirect to spa.redirect

* Changed method to up App SPA redirect

* change method to Rest as other method not supported

* added shell type in action

* reviewing all variables.

* declaring outputs on job

* added a echo step

* Update step output to correct output value

* fixing errors

* removed spacing

* updated steps to remove the URL after PR

* fixing errors

* fixing errors

* adding logic to see if URL exists

* updated Prod workflow
  • Loading branch information
desousamario85 authored Jan 22, 2025
1 parent 90a7913 commit 194b511
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 86 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/azure-static-web-apps-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,22 @@ jobs:
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Azure Login
run: az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
# Login to Azure
- name: Login to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Add Redirect URI
if: github.event_name == 'pull_request'
run: |
az ad app update --id 9b80eb43-d75a-43e3-8104-0d6d0f0b41ec --add web.redirectUris ${{ steps.builddeploy.outputs.deploymentUrl }}
$currentRedirectUris = az rest --method "get" --uri "https://graph.microsoft.com/v1.0/applications/6f3836b2-9449-45e7-aa62-810cbeaa6c5d" --headers '{"Content-Type": "application/json"}' -o json --query "spa.redirectUris"
$newRedirectUri = "${{ steps.builddeploy.outputs.static_web_app_url }}"
$updatedRedirectUris = $currentRedirectUris | ConvertFrom-Json
if ($updatedRedirectUris -notcontains $newRedirectUri) {
$updatedRedirectUris += $newRedirectUri
$updatedRedirectUrisJson = $updatedRedirectUris | ConvertTo-Json -Depth 10 -Compress
$jsonStringWithSingleQuotes = $updatedRedirectUrisJson -replace '"', "'"
az rest --method "patch" --uri "https://graph.microsoft.com/v1.0/applications/6f3836b2-9449-45e7-aa62-810cbeaa6c5d" --headers "{'Content-Type': 'application/json'}" --body "{'spa': {'redirectUris': $jsonStringWithSingleQuotes}}"
}
shell: pwsh
31 changes: 26 additions & 5 deletions .github/workflows/azure-static-web-apps-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
outputs:
deploymentUrl: ${{ steps.builddeploy.outputs.deploymentUrl }}
permissions:
contents: read
pull-requests: write
Expand Down Expand Up @@ -52,20 +54,32 @@ jobs:
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: '/tabs' # App source code path
api_location: '' # Api source code path - optional
output_location: 'build' # Built app content directory - optional
output_location: 'build' # Built app content directory - optional
###### End of Repository/Build Configurations ######

- name: Install Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Azure Login
run: az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
# Login to Azure
- name: Login to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Add Redirect URI
if: github.event_name == 'pull_request'
run: |
az ad app update --id 9b80eb43-d75a-43e3-8104-0d6d0f0b41ec --add web.redirectUris ${{ steps.builddeploy.outputs.deploymentUrl }}
$currentRedirectUris = az rest --method "get" --uri "https://graph.microsoft.com/v1.0/applications/6f3836b2-9449-45e7-aa62-810cbeaa6c5d" --headers '{"Content-Type": "application/json"}' -o json --query "spa.redirectUris"
$newRedirectUri = "${{ steps.builddeploy.outputs.static_web_app_url }}"
$updatedRedirectUris = $currentRedirectUris | ConvertFrom-Json
if ($updatedRedirectUris -notcontains $newRedirectUri) {
$updatedRedirectUris += $newRedirectUri
$updatedRedirectUrisJson = $updatedRedirectUris | ConvertTo-Json -Depth 10 -Compress
$jsonStringWithSingleQuotes = $updatedRedirectUrisJson -replace '"', "'"
az rest --method "patch" --uri "https://graph.microsoft.com/v1.0/applications/6f3836b2-9449-45e7-aa62-810cbeaa6c5d" --headers "{'Content-Type': 'application/json'}" --body "{'spa': {'redirectUris': $jsonStringWithSingleQuotes}}"
}
shell: pwsh

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
Expand All @@ -74,7 +88,14 @@ jobs:
steps:
- name: Remove Redirect URI
run: |
az ad app update --id 9b80eb43-d75a-43e3-8104-0d6d0f0b41ec --remove web.redirectUris ${{ steps.builddeploy.outputs.deploymentUrl }}
$currentRedirectUris = az rest --method "get" --uri "https://graph.microsoft.com/v1.0/applications/6f3836b2-9449-45e7-aa62-810cbeaa6c5d" --headers '{"Content-Type": "application/json"}' -o json --query "spa.redirectUris"
$newRedirectUri = "${{ steps.builddeploy.outputs.static_web_app_url }}"
$updatedRedirectUris = $currentRedirectUris | ConvertFrom-Json
$updatedRedirectUris = $updatedRedirectUris | Where-Object { $_ -ne $newRedirectUri }
$updatedRedirectUrisJson = $updatedRedirectUris | ConvertTo-Json -Depth 10 -Compress
$jsonStringWithSingleQuotes = $updatedRedirectUrisJson -replace '"', "'"
az rest --method "patch" --uri "https://graph.microsoft.com/v1.0/applications/6f3836b2-9449-45e7-aa62-810cbeaa6c5d" --headers "{'Content-Type': 'application/json'}" --body "{'spa': {'redirectUris': $jsonStringWithSingleQuotes}}"
shell: pwsh

- name: Close Pull Request
id: closepullrequest
Expand Down
78 changes: 0 additions & 78 deletions .github/workflows/manual_azure-static-web-apps-test.yml

This file was deleted.

0 comments on commit 194b511

Please sign in to comment.