Skip to content

Commit

Permalink
Deploying AL-Go from main (37e4e3fac9276ad13dc998d03f7bf0fdad577d19) …
Browse files Browse the repository at this point in the history
…to main (#29)

Deploying AL-Go from main (37e4e3fac9276ad13dc998d03f7bf0fdad577d19) to
main

Co-authored-by: microsoft <microsoft@users.noreply.github.com>
  • Loading branch information
bcbuild-github-agent and microsoft authored Sep 27, 2023
1 parent 9584936 commit 01fbe1e
Show file tree
Hide file tree
Showing 22 changed files with 362 additions and 666 deletions.
16 changes: 7 additions & 9 deletions .AL-Go/cloudDevEnv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ $webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumen
$webClient.Encoding = [System.Text.Encoding]::UTF8
Write-Host "Downloading GitHub Helper module"
$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.2/Github-Helper.psm1', $GitHubHelperPath)
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.3/Github-Helper.psm1', $GitHubHelperPath)
Write-Host "Downloading AL-Go Helper script"
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.2/AL-Go-Helper.ps1', $ALGoHelperPath)
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.3/AL-Go-Helper.ps1', $ALGoHelperPath)

Import-Module $GitHubHelperPath
. $ALGoHelperPath -local
Expand All @@ -31,13 +31,13 @@ $project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot
Clear-Host
Write-Host
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ ______
/ ____| | | | | __ \ | ____|
_____ _ _ _____ ______
/ ____| | | | | __ \ | ____|
| | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __
| | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / /
| |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V /
\_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/
| |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V /
\_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/
'@

Write-Host @'
Expand All @@ -51,8 +51,6 @@ if (Test-Path (Join-Path $PSScriptRoot "NewBcContainer.ps1")) {
Write-Host -ForegroundColor Red "WARNING: The project has a NewBcContainer override defined. Typically, this means that you cannot run a cloud development environment"
}

$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME

Write-Host

if (-not $environmentName) {
Expand Down
14 changes: 7 additions & 7 deletions .AL-Go/localDevEnv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ $webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumen
$webClient.Encoding = [System.Text.Encoding]::UTF8
Write-Host "Downloading GitHub Helper module"
$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.2/Github-Helper.psm1', $GitHubHelperPath)
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.3/Github-Helper.psm1', $GitHubHelperPath)
Write-Host "Downloading AL-Go Helper script"
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.2/AL-Go-Helper.ps1', $ALGoHelperPath)
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.3/AL-Go-Helper.ps1', $ALGoHelperPath)

Import-Module $GitHubHelperPath
. $ALGoHelperPath -local
Expand All @@ -34,13 +34,13 @@ $project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot
Clear-Host
Write-Host
Write-Host -ForegroundColor Yellow @'
_ _ _____ ______
| | | | | __ \ | ____|
_ _ _____ ______
| | | | | __ \ | ____|
| | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __
| | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / /
| |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V /
|______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/
| |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V /
|______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/
'@

Write-Host @'
Expand Down
72 changes: 68 additions & 4 deletions .github/RELEASENOTES.copy.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
## v3.3

### Issues

- Issue 227 Feature request: Allow deployments with "Schema Sync Mode" = Force
- Issue 519 Deploying to onprem environment
- Issue 520 Automatic deployment to environment with annotation
- Issue 592 Internal Server Error when publishing
- Issue 557 Deployment step fails when retried
- After configuring deployment branches for an environment in GitHub and setting Deployment Branch Policy to **Protected Branches**, AL-Go for GitHub would fail during initialization (trying to get environments for deployment)
- The DetermineDeploymentEnvironments doesn't work in private repositories (needs the GITHUB_TOKEN)
- Issue 683 Settings from GitHub variables ALGoRepoSettings and ALGoOrgSettings are not applied during build pipeline
- Issue 708 Inconsistent AuthTokenSecret Behavior in Multiple Projects: 'Secrets are not available'

### Breaking changes

Earlier, you could specify a mapping to an environment name in an environment secret called `<environmentname>_EnvironmentName`, `<environmentname>-EnvironmentName` or just `EnvironmentName`. You could also specify the projects you want to deploy to an environment as an environment secret called `Projects`.

This mechanism is no longer supported and you will get an error if your repository has these secrets. Instead you should use the `DeployTo<environmentName>` setting described below.

Earlier, you could also specify the projects you want to deploy to an environment in a setting called `<environmentName>_Projects` or `<environmentName>-Projects`. This is also no longer supported. Instead use the `DeployTo<environmentName>` and remove the old settings.

### New Actions
- `DetermineDeliveryTargets`: Determine which delivery targets should be used for delivering artifacts from the build job.
- `DetermineDeploymentEnvironments`: Determine which deployment environments should be used for the workflow.

### New Settings
- `projectName`: project setting used as friendly name for an AL-Go project, to be used in the UI for various workflows, e.g. CICD, Pull Request Build.
- `fullBuildPatterns`: used by `DetermineProjectsToBuild` action to specify changes in which files and folders would trigger a full build (building all AL-Go projects).
- `excludeEnvironments`: used by `DetermineDeploymentEnvironments` action to exclude environments from the list of environments considered for deployment.
- `deployTo<environmentName>`: is not really new, but has new properties. The complete list of properties is here:
- **EnvironmentType** = specifies the type of environment. The environment type can be used to invoke a custom deployment. (Default SaaS)
- **EnvironmentName** = specifies the "real" name of the environment if it differs from the GitHub environment
- **Branches** = an array of branch patterns, which are allowed to deploy to this environment. (Default [ "main" ])
- **Projects** = In multi-project repositories, this property can be a comma separated list of project patterns to deploy to this environment. (Default *)
- **SyncMode** = ForceSync if deployment to this environment should happen with ForceSync, else Add. If deploying to the development endpoint you can also specify Development or Clean. (Default Add)
- **ContinuousDeployment** = true if this environment should be used for continuous deployment, else false. (Default: AL-Go will continuously deploy to sandbox environments or environments, which doesn't end in (PROD) or (FAT)
- **runs-on** = specifies which GitHub runner to use when deploying to this environment. (Default is settings.runs-on)

### Custom Deployment

By specifying a custom EnvironmentType in the DeployTo structure for an environment, you can now add a script in the .github folder called `DeployTo<environmentType>.ps1`. This script will be executed instead of the standard deployment mechanism with the following parameters in a HashTable:

| Parameter | Description | Example |
| --------- | :--- | :--- |
| `$parameters.type` | Type of delivery (CD or Release) | CD |
| `$parameters.apps` | Apps to deploy | /home/runner/.../GHP-Common-main-Apps-2.0.33.0.zip |
| `$parameters.EnvironmentType` | Environment type | SaaS |
| `$parameters.EnvironmentName` | Environment name | Production |
| `$parameters.Branches` | Branches which should deploy to this environment (from settings) | main,dev |
| `$parameters.AuthContext` | AuthContext in a compressed Json structure | {"refreshToken":"mytoken"} |
| `$parameters.BranchesFromPolicy` | Branches which should deploy to this environment (from GitHub environments) | main |
| `$parameters.Projects` | Projects to deploy to this environment | |
| `$parameters.ContinuousDeployment` | Is this environment setup for continuous deployment | false |
| `$parameters."runs-on"` | GitHub runner to be used to run the deployment script | windows-latest |

### Status Checks in Pull Requests

AL-Go for GitHub now adds status checks to Pull Requests Builds. In your GitHub branch protection rules, you can set up "Pull Request Status Check" to be a required status check to ensure Pull Request Builds succeed before merging.

### Secrets in AL-Go for GitHub
In v3.2 of AL-Go for GitHub, all secrets requested by AL-Go for GitHub were available to all steps in a job one compressed JSON structure in env:Secrets.
With this update, only the steps that actually requires secrets will have the secrets available.

## v3.2

### Issues
Expand Down Expand Up @@ -65,13 +129,13 @@ All these actions now uses the selected branch in the **Run workflow** dialog as

### New Settings

- `UseCompilerFolder`: Setting useCompilerFolder to true causes your pipelines to use containerless compiling. Unless you also set `doNotPublishApps` to true, setting useCompilerFolder to true won't give you any performance advantage, since AL-Go for GitHub will still need to create a container in order to publish and test the apps. In the future, publishing and testing will be split from building and there will be other options for getting an instance of Business Central for publishing and testing.
- `UseCompilerFolder`: Setting useCompilerFolder to true causes your pipelines to use containerless compiling. Unless you also set `doNotPublishApps` to true, setting useCompilerFolder to true won't give you any performance advantage, since AL-Go for GitHub will still need to create a container in order to publish and test the apps. In the future, publishing and testing will be split from building and there will be other options for getting an instance of Business Central for publishing and testing.
- `vsixFile`: vsixFile should be a direct download URL to the version of the AL Language extension you want to use for building the project or repo. By default, AL-Go will use the AL Language extension that comes with the Business Central Artifacts.

### New Workflows

- **_BuildALGoProject** is a reusable workflow that unites the steps for building an AL-Go projects. It has been reused in the following workflows: _CI/CD_, _Pull Request Build_, _NextMinor_, _NextMajor_ and _Current_.
The workflow appears under the _Actions_ tab in GitHub, but it is not actionable in any way.
The workflow appears under the _Actions_ tab in GitHub, but it is not actionable in any way.

### New Actions

Expand Down Expand Up @@ -208,7 +272,7 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat
- Issue #273 Potential security issue in Pull Request Handler in Open Source repositories
- Issue #303 PullRequestHandler fails on added files
- Issue #299 Multi-project repositories build all projects on Pull Requests
- Issue #291 Issues with new Pull Request Handler
- Issue #291 Issues with new Pull Request Handler
- Issue #287 AL-Go pipeline fails in ReadSettings step

### Changes
Expand Down Expand Up @@ -323,7 +387,7 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat
```
"ConditionalSettings": [
{
"branches": [
"branches": [
"feature/*"
],
"settings": {
Expand Down
37 changes: 9 additions & 28 deletions .github/workflows/AddExistingAppOrTestApp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,57 +41,38 @@ jobs:

- name: Initialize the workflow
id: init
uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.2
uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.3
with:
shell: powershell
eventId: "DO0090"

- name: Read settings
uses: microsoft/AL-Go-Actions/ReadSettings@v3.2
if: github.event.inputs.useGhTokenWorkflow == 'true'
uses: microsoft/AL-Go-Actions/ReadSettings@v3.3
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}

- name: Read secrets
uses: microsoft/AL-Go-Actions/ReadSecrets@v3.2
if: github.event.inputs.useGhTokenWorkflow == 'true'
id: ReadSecrets
uses: microsoft/AL-Go-Actions/ReadSecrets@v3.3
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
gitHubSecrets: ${{ toJson(secrets) }}
getSecrets: 'ghTokenWorkflow'

- name: CalculateToken
id: CalculateToken
env:
useGhTokenWorkflow: ${{ github.event.inputs.useGhTokenWorkflow }}
run: |
$ghToken = '${{ secrets.GITHUB_TOKEN }}'
if ($env:useGhTokenWorkflow -eq 'true') {
$secrets = $env:Secrets | ConvertFrom-Json
if ($secrets.GHTOKENWORKFLOW) {
$ghToken = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($secrets.GHTOKENWORKFLOW))
}
else {
Write-Host "::Warning::GHTOKENWORKFLOW secret not found. Using GITHUB_TOKEN."
}
}
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "ghToken=$ghToken"
getSecrets: 'TokenForPush'
useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}'

- name: Add existing app
uses: microsoft/AL-Go-Actions/AddExistingApp@v3.2
uses: microsoft/AL-Go-Actions/AddExistingApp@v3.3
with:
shell: powershell
token: ${{ steps.CalculateToken.outputs.ghToken }}
token: ${{ steps.ReadSecrets.outputs.TokenForPush }}
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
project: ${{ github.event.inputs.project }}
url: ${{ github.event.inputs.url }}
directCommit: ${{ github.event.inputs.directCommit }}

- name: Finalize the workflow
if: always()
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.2
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.3
with:
shell: powershell
eventId: "DO0090"
Expand Down
Loading

0 comments on commit 01fbe1e

Please sign in to comment.