Skip to content

Commit

Permalink
Environment URL (#751)
Browse files Browse the repository at this point in the history
This PR will add the URL of the environment being deployed to underneath
the Environment name in the Build summary, like:

![image](https://github.com/microsoft/AL-Go/assets/10775043/a7abe194-618f-4651-a21f-f761342e6a4a)

It is implemented in the Publish To Environment workflow and for
Continuous Deployment in the CI/CD workflow.

![image](https://github.com/microsoft/AL-Go/assets/10775043/421d4402-b0b1-48af-b393-ce6318351f75)

and also supports custom deployment.

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk authored Oct 3, 2023
1 parent 28a355f commit 3460d16
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Actions/Deploy/Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ try {
throw "Authentication failed. $([environment]::Newline) $($_.exception.message)"
}

Write-Host "$($bcContainerHelperConfig.baseUrl.TrimEnd('/'))/$($bcAuthContext.tenantId)/$($deploymentSettings.EnvironmentName)/deployment/url"
$response = Invoke-RestMethod -UseBasicParsing -Method Get -Uri "$($bcContainerHelperConfig.baseUrl.TrimEnd('/'))/$($bcAuthContext.tenantId)/$($deploymentSettings.EnvironmentName)/deployment/url"
$environmentUrl = "$($bcContainerHelperConfig.baseUrl.TrimEnd('/'))/$($bcAuthContext.tenantId)/$($deploymentSettings.EnvironmentName)"
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "environmentUrl=$environmentUrl"
Write-Host "EnvironmentUrl: $environmentUrl"
$response = Invoke-RestMethod -UseBasicParsing -Method Get -Uri "$environmentUrl/deployment/url"
if ($response.Status -eq "DoesNotExist") {
OutputError -message "Environment with name $($deploymentSettings.EnvironmentName) does not exist in the current authorization context."
exit
Expand Down
4 changes: 3 additions & 1 deletion Actions/Deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ Deploy Apps to online environment
| type | | Type of delivery (CD or Release) | CD |

## OUTPUT
none
| Name | Description |
| :-- | :-- |
| environmentUrl | The URL for the environment. This URL is presented in the Deploy Step in summary under the environment name |
5 changes: 5 additions & 0 deletions Actions/Deploy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ inputs:
deploymentEnvironmentsJson:
description: The settings for all Deployment Environments
required: true
outputs:
environmentUrl:
description: The URL of the deployed environment
value: ${{ steps.Deploy.outputs.environmentUrl }}
runs:
using: composite
steps:
- name: run
shell: ${{ inputs.shell }}
id: Deploy
env:
_token: ${{ inputs.token }}
_parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
Expand Down
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ AL-Go for GitHub allows you to build and test using insider builds without any e
### New Settings
- `enableExternalRulesets`: set this setting to true if you want to allow AL-Go to automatically download external references in rulesets.

### Deployment
Environment URL is now displayed underneath the environment being deployed to in the build summary. For Custom Deployment, the script can set the GitHub Output variable `environmentUrl` in order to show a custom URL.

## v3.3

Expand Down
2 changes: 2 additions & 0 deletions Templates/AppSource App/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ jobs:
name: Deploy to ${{ matrix.environment }}
environment:
name: ${{ matrix.environment }}
url: ${{ steps.Deploy.outputs.environmentUrl }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -187,6 +188,7 @@ jobs:
getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects'

- name: Deploy
id: Deploy
uses: microsoft/AL-Go-Actions/Deploy@main
env:
Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
name: Deploy to ${{ matrix.environment }}
environment:
name: ${{ matrix.environment }}
url: ${{ steps.Deploy.outputs.environmentUrl }}
env:
deviceCode: ${{ needs.Initialization.outputs.deviceCode }}
steps:
Expand Down Expand Up @@ -144,6 +145,7 @@ jobs:
getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects'

- name: Deploy
id: Deploy
uses: microsoft/AL-Go-Actions/Deploy@main
env:
Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}'
Expand Down
2 changes: 2 additions & 0 deletions Templates/Per Tenant Extension/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ jobs:
name: Deploy to ${{ matrix.environment }}
environment:
name: ${{ matrix.environment }}
url: ${{ steps.Deploy.outputs.environmentUrl }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -187,6 +188,7 @@ jobs:
getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects'

- name: Deploy
id: Deploy
uses: microsoft/AL-Go-Actions/Deploy@main
env:
Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
name: Deploy to ${{ matrix.environment }}
environment:
name: ${{ matrix.environment }}
url: ${{ steps.Deploy.outputs.environmentUrl }}
env:
deviceCode: ${{ needs.Initialization.outputs.deviceCode }}
steps:
Expand Down Expand Up @@ -144,6 +145,7 @@ jobs:
getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects'

- name: Deploy
id: Deploy
uses: microsoft/AL-Go-Actions/Deploy@main
env:
Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}'
Expand Down
1 change: 1 addition & 0 deletions Tests/Deploy.Action.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Describe "Deploy Action Tests" {
$permissions = [ordered]@{
}
$outputs = [ordered]@{
"environmentUrl" = "The URL of the deployed environment"
}
YamlTest -scriptRoot $scriptRoot -actionName $actionName -actionScript $actionScript -permissions $permissions -outputs $outputs
}
Expand Down

0 comments on commit 3460d16

Please sign in to comment.