Skip to content

Commit

Permalink
Tejasd1990 iostreams fix (#39)
Browse files Browse the repository at this point in the history
* update README. Add yaml example that ensures az resource group created before arm deploy

* add RGLocation env variable in readme yaml example

* readme yaml example using azurecli for rg creation

* updated yaml examples names to 'AzureARMSample'

* modifying streams for exec (#35)

Co-authored-by: Tejas Deshpande <[email protected]>

* Add changes

Co-authored-by: Francisco Vilches <[email protected]>
Co-authored-by: Tejas Deshpande <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
4 people committed Apr 15, 2021
1 parent 70ed799 commit 9e83c24
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 17 deletions.
55 changes: 51 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Every template output will be exported as output.
## Example
```yml
```yaml
on: [push]
name: AzureLoginSample
name: AzureARMSample

jobs:
build-and-deploy:
Expand All @@ -57,8 +57,55 @@ jobs:
parameters: storageAccountType=Standard_LRS
```
## Another example on how to use this Action to use get the output of ARM template
In this exmaple, our template outputs `containerName`.
## Another example which ensures the Azure Resource Group exists before ARM deployment
In the preceeding example there is a pre-requisite that an existing Azure Resource Group named ```github-action-arm-rg``` must already exist.

The below example makes use of the [Azure CLI Action](https://github.com/marketplace/actions/azure-cli-action) to ensure the resource group is created before doing an ARM deployment.

## Steps
When generating your credentials (in this example we store in a secret named ```AZURE_CREDENTIALS```) you will need to specify a scope at the subscription level.

```azurecli
az ad sp create-for-rbac --name "{sp-name}" --sdk-auth --role contributor --scopes /subscriptions/{subscription-id}
```

See [Configure deployment credentials](https://github.com/marketplace/actions/azure-login#configure-deployment-credentials).

## Example
```yaml
on: [push]
name: AzureARMSample
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
ResourceGroupName: github-action-arm-rg
ResourceGroupLocation: "Australia East"
steps:
- uses: actions/checkout@master
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: Azure/CLI@v1
with:
inlineScript: |
#!/bin/bash
if $(az group exists --name ${{ env.ResourceGroupName }}) ; then
echo "Azure resource group already exists, skipping creation..."
else
az group create --name ${{ env.ResourceGroupName }} --location ${{ env.ResourceGroupLocation }}
echo "Azure resource group created"
fi
- uses: azure/arm-deploy@v1
with:
resourceGroupName: ${{ env.ResourceGroupName }}
template: ./azuredeploy.json
parameters: storageAccountType=Standard_LRS
```

## Another example on how to use this Action to get the output of ARM template
In this example, our template outputs `containerName`.

## Steps
```yaml
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/deploy/scope_managementgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export async function DeployManagementGroupScope(azPath: string, region: string,
stderr: (data: BufferSource) => {
core.error(data.toString());
},
stdline: (data: string) => {
if (!data.startsWith("[command]"))
commandOutput += data;
// console.log(data);
stdout: (data: BufferSource) => {
commandOutput += data.toString();
// console.log(data.toString());
},
debug: (data: string) => {
core.debug(data);
}
}
}
const validateOptions: ExecOptions = {
Expand Down
10 changes: 6 additions & 4 deletions src/deploy/scope_resourcegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ export async function DeployResourceGroupScope(azPath: string, resourceGroupName
stderr: (data: BufferSource) => {
core.error(data.toString());
},
stdline: (data: string) => {
if (!data.startsWith("[command]"))
commandOutput += data;
// console.log(data);
stdout: (data: BufferSource) => {
commandOutput += data.toString();
// console.log(data.toString());
},
debug: (data: string) => {
core.debug(data);
}
}
}
const validateOptions: ExecOptions = {
Expand Down
10 changes: 6 additions & 4 deletions src/deploy/scope_subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export async function DeploySubscriptionScope(azPath: string, region: string, te
stderr: (data: BufferSource) => {
core.error(data.toString());
},
stdline: (data: string) => {
if (!data.startsWith("[command]"))
commandOutput += data;
// console.log(data);
stdout: (data: BufferSource) => {
commandOutput += data.toString();
// console.log(data.toString());
},
debug: (data: string) => {
core.debug(data);
}
}
}
const validateOptions: ExecOptions = {
Expand Down

0 comments on commit 9e83c24

Please sign in to comment.