Deploy from [PPPreview] to [PPPreview] #119
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: Deploy | |
run-name: "Deploy from [${{ github.ref_name }}] to [${{ inputs.branch }}]" | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: Branch to deploy to (default is main) - (NOTE Use preview when deploying preview releases on microsoft/al-go) | |
required: false | |
default: 'main' | |
copyToMain: | |
description: Additionally deploy templates to main+preview branch? (Y/N) - (NOTE Only use Yes when deploying ordinary releases on microsoft/al-go) | |
required: false | |
default: 'N' | |
defaultBcContainerHelperVersion: | |
description: Which version of BcContainerHelper to use? (latest, preview, private, a specific version number or a direct download URL like https://github.com/freddydk/navcontainerhelper/archive/master.zip - leave empty to use latest) | |
required: false | |
default: '' | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
Deploy: | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: CheckUser | |
run: | | |
$threeMusketeers = @("freddydk", "aholstrup1", "mazhelez") | |
if ("$ENV:GITHUB_REPOSITORY" -eq "microsoft/AL-Go" -and "$ENV:GITHUB_ACTOR" -notin $threeMusketeers) { | |
Write-Host "::Error::You cannot run deploy and collect in the microsoft/AL-Go repo" | |
exit 1 | |
} | |
- name: Deploy | |
run: | | |
$ErrorActionPreference = "Stop" | |
Set-StrictMode -Version 2.0 | |
try { | |
$token = '${{ Secrets.OrgPAT }}' | |
if (!$token) { | |
throw "In order to run the Deploy workflow, you need a Secret called OrgPAT containing a valid Personal Access Token" | |
} | |
else { | |
$githubOwner = "$ENV:GITHUB_REPOSITORY_OWNER" | |
$settings = [ordered]@{ | |
"githubOwner" = $githubOwner | |
"actionsRepo" = "AL-Go-Actions" | |
"perTenantExtensionRepo" = "AL-Go-PTE" | |
"appSourceAppRepo" = "AL-Go-AppSource" | |
"branch" = '${{ github.event.inputs.branch }}' | |
"copyToMain" = ('${{ github.event.inputs.copyToMain }}' -eq 'Y') | |
"localFolder" = "" | |
"baseFolder" = [System.IO.Path]::GetTempPath() | |
"defaultBcContainerHelperVersion" = '${{ github.event.inputs.defaultBcContainerHelperVersion }}' | |
} | |
$settingsFile = Join-Path $settings.baseFolder "deploy.json" | |
$settings | ConvertTo-Json | Set-Content $settingsFile -Encoding UTF8 | |
. ".\Internal\Deploy.ps1" -configName $settingsFile -githubOwner $githubOwner -token $token -github | |
} | |
} | |
catch { | |
Write-Host "::Error::Error deploying repositories. The error was $($_.Exception.Message)" | |
exit 1 | |
} |