-
Notifications
You must be signed in to change notification settings - Fork 158
/
entrypoint.ps1
67 lines (55 loc) · 1.81 KB
/
entrypoint.ps1
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
#!/usr/bin/pwsh
Import-Module $PSScriptRoot/src/AzOps.psd1 -Force
. $PSScriptRoot/src/private/Start-AzOpsNativeExecution.ps1
function Logging {
process {
if ($env:INPUT_VERBOSE -eq "true") {
$PSDefaultParameterValues['*-AzOps*:Verbose'] = $true
}
if ($env:INPUT_DEBUG -eq "true") {
$PSDefaultParameterValues['*-AzOps*:Debug'] = $true
}
}
}
function Initialization {
begin {
try {
# Create [pscredential]
$credentials = ($env:INPUT_AZURE_CREDENTIALS | ConvertFrom-Json)
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList $credentials.clientId, ($credentials.clientSecret | ConvertTo-SecureString -AsPlainText -Force)
# Connect azure account
Connect-AzAccount -TenantId $credentials.tenantId -ServicePrincipal -Credential $credential -SubscriptionId $credentials.subscriptionId -WarningAction SilentlyContinue | Out-Null
# Configure git
Start-AzOpsNativeExecution {
git config --global user.email $env:INPUT_GITHUB_EMAIL
git config --global user.name $env:INPUT_GITHUB_USERNAME
} | Out-Host
}
catch {
Write-Error -Message $PSItem.Exception.Message
exit 1
}
}
process {
try {
switch ($env:INPUT_MODE) {
"Push" {
# Invoke push operation
Invoke-AzOpsGitPush
}
"Pull" {
# Invoke pull operation
Invoke-AzOpsGitPull
}
}
}
catch {
Write-Error -Message $PSItem.Exception.Message
exit 1
}
}
end {
}
}
Logging
Initialization