This repository has been archived by the owner on Aug 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump version
- Loading branch information
Showing
10 changed files
with
231 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Advanced example on how to use this Action | ||
In this exmaple we deploy 2 templates (for the sake of the example the same template) but the seccond one depends on the first one as we need first the output of first one and seccond we need to override a parameter in the seccond template. | ||
Our template has two outputs `location` and `containerName`. But here we only interested in `containerName`, the first template will output that one and the seccond one requires that and appends `-overriden` so we can see it got overriden. | ||
|
||
## Steps | ||
```yaml | ||
- uses: whiteducksoftware/azure-arm-action@v3 | ||
id: deploy | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
resourceGroupName: azurearmaction | ||
templateLocation: examples/template/template.json | ||
parameters: examples/template/parameters.json | ||
deploymentName: github-advanced-test | ||
``` | ||
Here we see a normal use of the Action, we pass the template as json file as well as the parameters. If we look into the `template.json` File we can see at the very bottom the defined outputs: | ||
```json | ||
{ | ||
.. | ||
"outputs": { | ||
... | ||
"containerName": { | ||
"type": "string", | ||
"value": "[parameters('containerName')]" | ||
} | ||
} | ||
} | ||
``` | ||
And we know our Action writes this output(s) to an action output variable with the same name, we can access it using `${{ steps.deploy.outputs.containerName }}` (Note: `deploy` comes from the `id` field from above.) | ||
|
||
If we now add a Shell script with a simple echo from that value, | ||
```yaml | ||
- run: echo ${{ steps.deploy.outputs.containerName }} | ||
``` | ||
we can see that on the console will be `github-action` printed. | ||
|
||
Now we add our seccond deployment which relies on that value and modfies the `containerName` parameter, | ||
```yaml | ||
- uses: whiteducksoftware/azure-arm-action@v3 | ||
id: deploy2 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
resourceGroupName: azurearmaction | ||
templateLocation: examples/template/template.json | ||
parameters: examples/template/parameters.json | ||
deploymentName: github-advanced-test | ||
overrideParameters: | | ||
containerName=${{ steps.deploy.outputs.containerName }}-overriden | ||
``` | ||
Look at the `overrideParameters` section, where we either could plug in another `parameter.json` File or we do it like here with line seperated key-value pairs. If we now add again a shell script to see our ouput, | ||
```yaml | ||
- run: echo ${{ steps.deploy2.outputs.containerName }} | ||
``` | ||
we can see that on the console will be `github-action-overriden` printed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Unit Tests | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
jobs: | ||
test_action_job: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- uses: whiteducksoftware/azure-arm-action@v3 | ||
id: deploy | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
resourceGroupName: azurearmaction | ||
templateLocation: examples/template/template.json | ||
parameters: examples/template/parameters.json | ||
deploymentName: github-advanced-test | ||
|
||
- run: echo ${{ steps.deploy.outputs.containerName }} | ||
|
||
- uses: whiteducksoftware/azure-arm-action@v3 | ||
id: deploy2 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
resourceGroupName: azurearmaction | ||
templateLocation: examples/template/template.json | ||
parameters: examples/template/parameters.json | ||
deploymentName: github-advanced-test | ||
overrideParameters: | | ||
containerName=${{ steps.deploy.outputs.containerName }}-overriden | ||
- run: echo ${{ steps.deploy2.outputs.containerName }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"containerName": { | ||
"value": "github-action" | ||
}, | ||
"location": { | ||
"value": "westeurope" | ||
}, | ||
"imageType": { | ||
"value": "Public" | ||
}, | ||
"imageName": { | ||
"value": "whiteduck/sample-mvc" | ||
}, | ||
"osType": { | ||
"value": "Linux" | ||
}, | ||
"numberCpuCores": { | ||
"value": "1" | ||
}, | ||
"memory": { | ||
"value": "0.5" | ||
}, | ||
"restartPolicy": { | ||
"value": "OnFailure" | ||
}, | ||
"ipAddressType": { | ||
"value": "Public" | ||
}, | ||
"ports": { | ||
"value": [ | ||
{ | ||
"port": "8080", | ||
"protocol": "TCP" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"location": { | ||
"type": "string" | ||
}, | ||
"containerName": { | ||
"type": "string" | ||
}, | ||
"imageType": { | ||
"type": "string", | ||
"allowedValues": [ | ||
"Public", | ||
"Private" | ||
] | ||
}, | ||
"imageName": { | ||
"type": "string" | ||
}, | ||
"osType": { | ||
"type": "string", | ||
"allowedValues": [ | ||
"Linux", | ||
"Windows" | ||
] | ||
}, | ||
"numberCpuCores": { | ||
"type": "string" | ||
}, | ||
"memory": { | ||
"type": "string" | ||
}, | ||
"restartPolicy": { | ||
"type": "string", | ||
"allowedValues": [ | ||
"OnFailure", | ||
"Always", | ||
"Never" | ||
] | ||
}, | ||
"ipAddressType": { | ||
"type": "string" | ||
}, | ||
"ports": { | ||
"type": "array" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"location": "[parameters('location')]", | ||
"name": "[parameters('containerName')]", | ||
"type": "Microsoft.ContainerInstance/containerGroups", | ||
"apiVersion": "2018-10-01", | ||
"properties": { | ||
"containers": [ | ||
{ | ||
"name": "[parameters('containerName')]", | ||
"properties": { | ||
"image": "[parameters('imageName')]", | ||
"resources": { | ||
"requests": { | ||
"cpu": "[int(parameters('numberCpuCores'))]", | ||
"memoryInGB": "[float(parameters('memory'))]" | ||
} | ||
}, | ||
"ports": "[parameters('ports')]" | ||
} | ||
} | ||
], | ||
"restartPolicy": "[parameters('restartPolicy')]", | ||
"osType": "[parameters('osType')]", | ||
"ipAddress": { | ||
"type": "[parameters('ipAddressType')]", | ||
"ports": "[parameters('ports')]" | ||
} | ||
}, | ||
"tags": {} | ||
} | ||
], | ||
"outputs": { | ||
"location": { | ||
"type": "string", | ||
"value": "[parameters('location')]" | ||
}, | ||
"containerName": { | ||
"type": "string", | ||
"value": "[parameters('containerName')]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters