Repository navigation
Expand file tree
/
Copy pathCreateOnlineDevelopmentEnvironment.yaml
More file actions
98 lines (87 loc) · 3.72 KB
/
Copy pathCreateOnlineDevelopmentEnvironment.yaml
File metadata and controls
98 lines (87 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: ' Create Online Dev. Environment'
on:
workflow_dispatch:
inputs:
environmentName:
description: Name of the online environment
required: true
reUseExistingEnvironment:
description: Reuse environment if it exists
required: false
default: 'N'
directCommit:
description: Direct COMMIT (Y/N)
required: false
default: 'N'
permissions:
contents: write
pull-requests: write
defaults:
run:
shell: powershell
env:
ALGoOrgSettings: ${{ vars.ALGoOrgSettings }}
ALGoRepoSettings: ${{ vars.ALGoRepoSettings }}
jobs:
CreateOnlineDevelopmentEnvironment:
runs-on: [ windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialize the workflow
id: init
uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.4
with:
shell: powershell
eventId: "DO0093"
- name: Read settings
uses: microsoft/AL-Go-Actions/ReadSettings@v2.4
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
- name: Read secrets
uses: microsoft/AL-Go-Actions/ReadSecrets@v2.4
env:
secrets: ${{ toJson(secrets) }}
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
settingsJson: ${{ env.Settings }}
secrets: 'adminCenterApiCredentials'
- name: Check AdminCenterApiCredentials / Initiate Device Login (open to see code)
run: |
$ErrorActionPreference = "STOP"
Set-StrictMode -version 2.0
$adminCenterApiCredentials = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($env:adminCenterApiCredentials))
if ($adminCenterApiCredentials) {
Write-Host "AdminCenterApiCredentials provided!"
}
else {
Write-Host "AdminCenterApiCredentials not provided, initiating Device Code flow"
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.4/AL-Go-Helper.ps1', $ALGoHelperPath)
. $ALGoHelperPath
$BcContainerHelperPath = DownloadAndImportBcContainerHelper -baseFolder $ENV:GITHUB_WORKSPACE
$authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0))
MaskValueInLog -value $authContext.deviceCode
$adminCenterApiCredentials = "{""deviceCode"":""$($authContext.deviceCode)""}"
Add-Content -Path $env:GITHUB_ENV -Value "adminCenterApiCredentials=$([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($adminCenterApiCredentials)))"
CleanupAfterBcContainerHelper -bcContainerHelperPath $bcContainerHelperPath
}
- name: Create Development Environment
uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@v2.4
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
environmentName: ${{ github.event.inputs.environmentName }}
reUseExistingEnvironment: ${{ github.event.inputs.reUseExistingEnvironment }}
directCommit: ${{ github.event.inputs.directCommit }}
adminCenterApiCredentials: ${{ env.adminCenterApiCredentials }}
- name: Finalize the workflow
if: always()
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.4
with:
shell: powershell
eventId: "DO0093"
telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}