Skip to content

Commit

Permalink
V1 (#2)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
segraef and segraef authored Mar 23, 2020
1 parent 0872419 commit cc8bcb6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# GitHub Action for Managing Azure Resources
# GitHub Action azdeploy

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/)
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>
One can also use this to delete a resource group, including all the resources within the resource group.

To log into a Azure, I recommend using [azlogin](https://github.com/segraef/azlogin) Action.
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.

## Usage

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

### Environment variables
## Requirements

segraef/azlogin@v1

## Variables

- `resourceGroupCommand`**Optional**.

Expand Down
40 changes: 14 additions & 26 deletions entry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ Param(
[string]$parametersFile
)

$resourceGroupName
$resourceGroupLocation
$resourceGroupCommand
$templateFile
$parametersFile

$context = Get-AzContext
if (!$context) {
Write-Output "No Azure context found! Please make sure azlogin has run before."
Expand All @@ -28,28 +22,22 @@ if ($resourceGroupCommand -and ($resourceGroupCommand -like "create")) {
if (-not (Get-AzResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue)) {
if ($resourceGroupLocation) {
New-AzResourceGroup -Name $resourceGroupName -Location "$resourceGroupLocation"

if ($templateFile -and $parametersFile) {
$DeploymentInputs = @{
Name = "$($env:GITHUB_WORKFLOW)-$($env:GITHUB_ACTOR)-$(Get-Date -Format yyyyMMddHHMMss)"
ResourceGroupName = "$resourceGroupName"
TemplateFile = "$templateFile"
TemplateParameterFile = "$parametersFile"
Mode = "Incremental"
Verbose = $true
ErrorAction = "Stop"
}

New-AzResourceGroupDeployment @DeploymentInputs
}
else {
Write-Output "Template or parameters file does not exist."
}
}
else {
Write-Output "resourceGroupLocation is not set."
exit
} elseif ($templateFile -and $parametersFile) {
$DeploymentInputs = @{
Name = "$($env:GITHUB_WORKFLOW)-$($env:GITHUB_ACTOR)-$(Get-Date -Format yyyyMMddHHMMss)"
ResourceGroupName = "$resourceGroupName"
TemplateFile = "$templateFile"
TemplateParameterFile = "$parametersFile"
Mode = "Incremental"
Verbose = $true
ErrorAction = "Stop"
}

New-AzResourceGroupDeployment @DeploymentInputs
}
else {
Write-Output "Template or parameters file does not exist."
}
} elseif ($resourceGroupCommand -like "delete") {
Write-Output "resourceGroupCommand is set to 'delete'. Removing $resourceGroupName now. "
Expand Down

0 comments on commit cc8bcb6

Please sign in to comment.