Skip to content

Commit cc8bcb6

Browse files
authored
V1 (#2)
* v1 * azdeploy * action.yml * azlogin * azdeploy * another one * let's try this * let's see * tpyos * -ErrorAction SilentlyContinue * location * typo * resourceGroupLocation * gci * indent * params * recurse * Get-Location * az * other path * go * workspace * testing delete * and * error handling * remove * test no azlogin * go * typo * typo * v1 * go * go * deploymentname * delete * delete * go * output * create * typo * elseif? Co-authored-by: Sebastian Gräf <segraef@microsoft.com>
1 parent 0872419 commit cc8bcb6

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# GitHub Action for Managing Azure Resources
1+
# GitHub Action azdeploy
22

3-
This action can be used to create or update a resource group in Azure using the [Azure Resource Manager templates](https://azure.microsoft.com/en-in/documentation/articles/resource-group-template-deploy/)
3+
This action can be used to create or update a resource group in Azure using the [Azure Resource Manager templates](https://azure.microsoft.com/en-in/documentation/articles/resource-group-template-deploy/).<br>
44
One can also use this to delete a resource group, including all the resources within the resource group.
55

6-
To log into a Azure, I recommend using [azlogin](https://github.com/segraef/azlogin) Action.
6+
To be able to deploy resources your Action needs to be logged into Azure. The Action [azlogin](https://github.com/segraef/azlogin) does that for you.
77

88
## Usage
99

@@ -18,7 +18,11 @@ To log into a Azure, I recommend using [azlogin](https://github.com/segraef/azlo
1818
1919
```
2020

21-
### Environment variables
21+
## Requirements
22+
23+
segraef/azlogin@v1
24+
25+
## Variables
2226

2327
- `resourceGroupCommand`**Optional**.
2428

entry.ps1

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ Param(
66
[string]$parametersFile
77
)
88

9-
$resourceGroupName
10-
$resourceGroupLocation
11-
$resourceGroupCommand
12-
$templateFile
13-
$parametersFile
14-
159
$context = Get-AzContext
1610
if (!$context) {
1711
Write-Output "No Azure context found! Please make sure azlogin has run before."
@@ -28,28 +22,22 @@ if ($resourceGroupCommand -and ($resourceGroupCommand -like "create")) {
2822
if (-not (Get-AzResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue)) {
2923
if ($resourceGroupLocation) {
3024
New-AzResourceGroup -Name $resourceGroupName -Location "$resourceGroupLocation"
31-
32-
if ($templateFile -and $parametersFile) {
33-
$DeploymentInputs = @{
34-
Name = "$($env:GITHUB_WORKFLOW)-$($env:GITHUB_ACTOR)-$(Get-Date -Format yyyyMMddHHMMss)"
35-
ResourceGroupName = "$resourceGroupName"
36-
TemplateFile = "$templateFile"
37-
TemplateParameterFile = "$parametersFile"
38-
Mode = "Incremental"
39-
Verbose = $true
40-
ErrorAction = "Stop"
41-
}
42-
43-
New-AzResourceGroupDeployment @DeploymentInputs
44-
}
45-
else {
46-
Write-Output "Template or parameters file does not exist."
47-
}
4825
}
49-
else {
50-
Write-Output "resourceGroupLocation is not set."
51-
exit
26+
} elseif ($templateFile -and $parametersFile) {
27+
$DeploymentInputs = @{
28+
Name = "$($env:GITHUB_WORKFLOW)-$($env:GITHUB_ACTOR)-$(Get-Date -Format yyyyMMddHHMMss)"
29+
ResourceGroupName = "$resourceGroupName"
30+
TemplateFile = "$templateFile"
31+
TemplateParameterFile = "$parametersFile"
32+
Mode = "Incremental"
33+
Verbose = $true
34+
ErrorAction = "Stop"
5235
}
36+
37+
New-AzResourceGroupDeployment @DeploymentInputs
38+
}
39+
else {
40+
Write-Output "Template or parameters file does not exist."
5341
}
5442
} elseif ($resourceGroupCommand -like "delete") {
5543
Write-Output "resourceGroupCommand is set to 'delete'. Removing $resourceGroupName now. "

0 commit comments

Comments
 (0)