diff --git a/.github/workflows/docker-build-release.yaml b/.github/workflows/docker-build-release.yaml index b7d4d5a..77bf2d1 100644 --- a/.github/workflows/docker-build-release.yaml +++ b/.github/workflows/docker-build-release.yaml @@ -13,6 +13,7 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@master + - uses: jerray/publish-docker-action@master with: username: ${{ secrets.DOCKER_USERNAME }} diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 09bd2cb..8fa2457 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -13,6 +13,7 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@master + - uses: jerray/publish-docker-action@master with: username: ${{ secrets.DOCKER_USERNAME }} diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 499ae5f..ff3f765 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -13,8 +13,10 @@ jobs: uses: actions/setup-go@v1 with: go-version: 1.14 + - name: Check out source code uses: actions/checkout@v1 + - name: Build env: GOPROXY: "https://proxy.golang.org" @@ -22,6 +24,7 @@ jobs: GOOS: linux GOARCH: amd64 run: go build -a -installsuffix cgo -ldflags="-w -s" . + - name: Test env: GOPROXY: "https://proxy.golang.org" diff --git a/README.md b/README.md index ee0c24f..3649739 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Additionally are the following outputs available: ## Usage ```yml -- uses: whiteducksoftware/azure-arm-action@v2.3 +- uses: whiteducksoftware/azure-arm-action@v3 with: creds: ${{ secrets.AZURE_CREDENTIALS }} resourceGroupName: @@ -56,14 +56,14 @@ Additionally are the following outputs available: ```yml on: [push] -name: AzureLoginSample +name: ARMActionSample jobs: build-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - uses: whiteducksoftware/azure-arm-action@v2.3 + - uses: whiteducksoftware/azure-arm-action@v3 with: creds: ${{ secrets.AZURE_CREDENTIALS }} resourceGroupName: diff --git a/action.yml b/action.yml index c98d027..0cebd4d 100644 --- a/action.yml +++ b/action.yml @@ -32,4 +32,4 @@ branding: icon: package runs: using: 'docker' - image: 'docker://whiteduck/azure-arm-action:v2.3' \ No newline at end of file + image: 'docker://whiteduck/azure-arm-action:v3' \ No newline at end of file diff --git a/examples/Advanced.md b/examples/Advanced.md index e69de29..22bd435 100644 --- a/examples/Advanced.md +++ b/examples/Advanced.md @@ -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. \ No newline at end of file diff --git a/examples/advanced-example.yaml b/examples/advanced-example.yaml new file mode 100644 index 0000000..3ec0861 --- /dev/null +++ b/examples/advanced-example.yaml @@ -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 }} \ No newline at end of file diff --git a/examples/template/parameters.json b/examples/template/parameters.json new file mode 100644 index 0000000..27ce39d --- /dev/null +++ b/examples/template/parameters.json @@ -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" + } + ] + } + } +} diff --git a/examples/template/template.json b/examples/template/template.json new file mode 100644 index 0000000..761eaea --- /dev/null +++ b/examples/template/template.json @@ -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')]" + } + } +} diff --git a/pkg/github/options.go b/pkg/github/options.go index 3a374ff..02fb508 100644 --- a/pkg/github/options.go +++ b/pkg/github/options.go @@ -130,7 +130,6 @@ func wrapReadRawParameters(v string) (interface{}, error) { return false default: return unicode.IsSpace(c) - } }