added default line type #15
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: CI/CD | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- 'README.md' | |
- '.github/**' | |
branches: [ main ] | |
pull_request: | |
paths-ignore: | |
- 'README.md' | |
- '.github/**' | |
defaults: | |
run: | |
shell: PowerShell | |
jobs: | |
Initialization: | |
runs-on: [ windows-latest ] | |
outputs: | |
telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} | |
settings: ${{ steps.ReadSettings.outputs.SettingsJson }} | |
projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} | |
projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} | |
environments: ${{ steps.ReadSettings.outputs.EnvironmentsJson }} | |
environmentCount: ${{ steps.ReadSettings.outputs.EnvironmentCount }} | |
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Initialize the workflow | |
id: init | |
uses: microsoft/AL-Go-Actions/WorkflowInitialize@v0.1 | |
with: | |
eventId: "DO0091" | |
- name: Read settings | |
id: ReadSettings | |
uses: microsoft/AL-Go-Actions/ReadSettings@v0.1 | |
with: | |
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} | |
getProjects: 'Y' | |
getEnvironments: '*' | |
CheckForUpdates: | |
runs-on: [ windows-latest ] | |
needs: [ Initialization ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@v0.1 | |
with: | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
get: TemplateUrl | |
- name: Check for updates to AL-Go system files | |
uses: microsoft/AL-Go-Actions/CheckForUpdates@v0.1 | |
with: | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
templateUrl: ${{ env.TemplateUrl }} | |
Build: | |
needs: [ Initialization ] | |
runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} | |
strategy: | |
matrix: | |
project: ${{ fromJson(needs.Initialization.outputs.projects) }} | |
fail-fast: false | |
name: Build ${{ matrix.project }} | |
outputs: | |
AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} | |
TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} | |
TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@v0.1 | |
with: | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
project: ${{ matrix.project }} | |
- name: Read secrets | |
uses: microsoft/AL-Go-Actions/ReadSecrets@v0.1 | |
env: | |
secrets: ${{ toJson(secrets) }} | |
with: | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
settingsJson: ${{ env.Settings }} | |
secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId' | |
- name: Run pipeline | |
uses: microsoft/AL-Go-Actions/RunPipeline@v0.1 | |
with: | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
Project: ${{ matrix.project }} | |
settingsJson: ${{ env.Settings }} | |
SecretsJson: ${{ env.RepoSecrets }} | |
- name: Calculate Artifact names | |
id: calculateArtifactNames | |
if: success() || failure() | |
run: | | |
$settings = '${{ env.Settings }}' | ConvertFrom-Json | |
$project = '${{ matrix.project }}' | |
if ($project -eq ".") { $project = $settings.RepoName } | |
$AppsArtifactsName = "$project-Apps-$($settings.repoVersion).$($settings.appBuild).$($settings.appRevision)" | |
$TestAppsArtifactsName = "$project-TestApps-$($settings.repoVersion).$($settings.appBuild).$($settings.appRevision)" | |
$TestResultsArtifactsName = "$project-TestResults" | |
'AppsArtifactsName','TestAppsArtifactsName','TestResultsArtifactsName' | ForEach-Object { | |
$value = (Get-Variable -Name $_).Value | |
Write-Host "::set-output name=$_::$value" | |
Add-Content -Path $env:GITHUB_ENV -Value "$_=$value" | |
} | |
- name: Publish artifacts - apps | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.appsArtifactsName }} | |
path: '${{ matrix.project }}/output/Apps/' | |
if-no-files-found: ignore | |
- name: Publish artifacts - test apps | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.testAppsArtifactsName }} | |
path: '${{ matrix.project }}/output/TestApps/' | |
if-no-files-found: ignore | |
- name: Publish artifacts - test results | |
uses: actions/upload-artifact@v2 | |
if: success() || failure() | |
with: | |
name: ${{ env.testResultsArtifactsName }} | |
path: '${{ matrix.project }}/TestResults.xml' | |
if-no-files-found: ignore | |
- name: Cleanup | |
if: always() | |
uses: microsoft/AL-Go-Actions/PipelineCleanup@v0.1 | |
with: | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
Project: ${{ matrix.project }} | |
Deploy: | |
runs-on: [ windows-latest ] | |
needs: [ Initialization, Build ] | |
if: ${{ github.event_name != 'pull request' && needs.Initialization.outputs.environmentCount > 0 }} | |
strategy: | |
matrix: | |
environment: ${{ fromJson(needs.Initialization.outputs.environments) }} | |
fail-fast: false | |
name: Deploy to ${{ matrix.environment }} | |
environment: | |
name: ${{ matrix.environment }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
path: '${{ github.workspace }}\artifacts' | |
- name: EnvName | |
id: envName | |
run: | | |
$envName = '${{ matrix.environment }}'.split(' ')[0] | |
Write-Host "::set-output name=envName::$envName" | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@v0.1 | |
- name: Read secrets | |
uses: microsoft/AL-Go-Actions/ReadSecrets@v0.1 | |
env: | |
secrets: ${{ toJson(secrets) }} | |
with: | |
settingsJson: ${{ env.Settings }} | |
secrets: '${{ steps.envName.outputs.envName }}-AuthContext,AuthContext' | |
- name: AuthContext | |
id: authContext | |
run: | | |
$authContext = [System.Environment]::GetEnvironmentVariable('${{ steps.envName.outputs.envName }}-AuthContext') | |
if ($authContext) { | |
Write-Host "Using ${{ steps.envName.outputs.envName }}-AuthContext secret" | |
} | |
else { | |
$authContext = [System.Environment]::GetEnvironmentVariable('AuthContext') | |
if ($authContext) { | |
Write-Host "Using AuthContext secret" | |
} | |
else { | |
Write-Host "::Error::No AuthContext provided" | |
exit 1 | |
} | |
} | |
Write-Host "::set-output name=authContext::$authContext" | |
Write-Host "set-output name=authContext::$authContext" | |
- name: Deploy | |
uses: microsoft/AL-Go-Actions/Deploy@v0.1 | |
env: | |
authContext: '${{ steps.authContext.outputs.authContext }}' | |
with: | |
type: 'CD' | |
projects: '${{ secrets.Projects }}' | |
environmentName: ${{ matrix.environment }} | |
artifacts: '${{ github.workspace }}\artifacts' | |
PostProcess: | |
if: always() | |
runs-on: [ windows-latest ] | |
needs: [ Initialization, Build, Deploy ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Finalize the workflow | |
id: PostProcess | |
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v0.1 | |
with: | |
eventId: "DO0091" | |
telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |