Deploy from [main] to [preview] #116
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 (NOTE: Use preview when deploying preview releases on microsoft/al-go)' | |
required: true | |
copyToMain: | |
description: 'Additionally deploy templates to main+preview branch? (Y/N) - (NOTE: Enter Y if this is a release to PROD 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 | |
env: | |
branch: ${{ github.event.inputs.branch }} | |
copyToMain: ${{ github.event.inputs.copyToMain }} | |
defaultBcContainerHelperVersion: ${{ github.event.inputs.defaultBcContainerHelperVersion }} | |
run: | | |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; 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" | |
$config = @{ | |
"githubOwner" = $githubOwner | |
"actionsRepo" = "AL-Go-Actions" | |
"perTenantExtensionRepo" = "AL-Go-PTE" | |
"appSourceAppRepo" = "AL-Go-AppSource" | |
"branch" = $env:branch | |
"copyToMain" = ($env:copyToMain -eq 'Y') | |
"defaultBcContainerHelperVersion" = $env:defaultBcContainerHelperVersion | |
} | |
. ".\Internal\Deploy.ps1" -config $config -token $token | |
} | |
} | |
catch { | |
Write-Host "::Error::Error deploying repositories. The error was $($_.Exception.Message)" | |
exit 1 | |
} |