Skip to content

Commit 8bfcd30

Browse files
committed
Add debug flag to action
This flag, turned off by default, can be enabled by the customer to debug their Azure CLI invocations.
1 parent 7125ae3 commit 8bfcd30

File tree

3 files changed

+73
-19
lines changed

3 files changed

+73
-19
lines changed

github-action/action.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,26 @@ inputs:
2323
default: "nginx.conf"
2424
transformed-nginx-config-directory-path:
2525
description: >
26-
'The transformed absolute path of the NGINX configuration directory in NGINXaaS for Azure deployment, example: "/etc/nginx/".
27-
If the "include" directive in the NGINX configuration files uses absolute paths, the path transformation
26+
'The transformed absolute path of the NGINX configuration directory in NGINXaaS for Azure deployment, example: "/etc/nginx/".
27+
If the "include" directive in the NGINX configuration files uses absolute paths, the path transformation
2828
can be used to overwrite the file paths when the action synchronizes the files to the NGINXaaS for Azure deployment.'
2929
required: false
3030
default: ""
3131
nginx-certificates:
3232
description: 'An array of JSON objects each with keys nginx_cert_name, keyvault_secret, certificate_virtual_path and key_virtual_path. Example: [{"certificateName": "server1", "keyvaultSecret": "https://...", "certificateVirtualPath": "/etc/ssl/certs/server1.crt", "keyVirtualPath": "/etc/ssl/certs/server1.key" }, {"name": "server2", "keyvaultSecret": "https://...", "certificateVirtualPath": "/etc/ssl/certs/server2.crt", "keyVirtualPath": "/etc/ssl/certs/server2.key" }] '
3333
required: false
34+
debug:
35+
description: "Enable/Disable debug output."
36+
required: false
37+
default: "false"
3438
runs:
3539
using: "composite"
3640
steps:
3741
- name: "Synchronize NGINX certificate(s) from the Git repository to an NGINXaaS for Azure deployment"
38-
run: ${{github.action_path}}/src/deploy-certificate.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --nginx_resource_location=${{ inputs.nginx-deployment-location }} --certificates=${{ toJSON(inputs.nginx-certificates) }}
42+
run: ${{github.action_path}}/src/deploy-certificate.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --nginx_resource_location=${{ inputs.nginx-deployment-location }} --certificates=${{ toJSON(inputs.nginx-certificates) }} --debug=${{ inputs.debug }}
3943
if: ${{ inputs.nginx-deployment-location != '' && inputs.nginx-certificates != '' }}
4044
shell: bash
4145
- name: "Synchronize NGINX configuration from the Git repository to an NGINXaaS for Azure deployment"
42-
run: ${{github.action_path}}/src/deploy-config.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --config_dir_path=${{ inputs.nginx-config-directory-path }} --root_config_file=${{ inputs.nginx-root-config-file }} --transformed_config_dir_path=${{ inputs.transformed-nginx-config-directory-path }}
46+
run: ${{github.action_path}}/src/deploy-config.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --config_dir_path=${{ inputs.nginx-config-directory-path }} --root_config_file=${{ inputs.nginx-root-config-file }} --transformed_config_dir_path=${{ inputs.transformed-nginx-config-directory-path }} --debug=${{ inputs.debug }}
4347
if: ${{ inputs.nginx-config-directory-path != '' }}
4448
shell: bash

github-action/src/deploy-certificate.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ case $i in
2525
certificates="${i#*=}"
2626
shift
2727
;;
28+
--debug=*)
29+
debug="${i#*=}"
30+
shift
31+
;;
2832
*)
2933
echo "Not matched option '${i#*=}' passed in."
3034
exit 1
@@ -120,8 +124,29 @@ do
120124

121125
if [ $do_nginx_arm_deployment -eq 1 ]
122126
then
127+
az_cmd=(
128+
"az"
129+
"deployment"
130+
"group"
131+
"create"
132+
"--name" "$template_deployment_name"
133+
"--resource-group" "$resource_group_name"
134+
"--template-file" "$template_file"
135+
"--parameters"
136+
"name=$nginx_cert_name"
137+
"location=$nginx_resource_location"
138+
"nginxDeploymentName=$nginx_deployment_name"
139+
"certificateVirtualPath=$nginx_cert_file"
140+
"keyVirtualPath=$nginx_key_file"
141+
"keyVaultSecretID=$keyvault_secret"
142+
"--verbose"
143+
)
144+
if [[ "$debug" == true ]]; then
145+
az_cmd+=("--debug")
146+
fi
147+
echo "${az_cmd[@]}"
123148
set +e
124-
az deployment group create --name "$template_deployment_name" --resource-group "$resource_group_name" --template-file "$template_file" --parameters name="$nginx_cert_name" location="$nginx_resource_location" nginxDeploymentName="$nginx_deployment_name" certificateVirtualPath="$nginx_cert_file" keyVirtualPath="$nginx_key_file" keyVaultSecretID="$keyvault_secret" --verbose
149+
"${az_cmd[@]}"
125150
set -e
126151
else
127152
echo "Skipping JSON object $i cert deployment with error:$err_msg"

github-action/src/deploy-config.sh

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@ do
88
case $i in
99
--subscription_id=*)
1010
subscription_id="${i#*=}"
11-
shift
11+
shift
1212
;;
1313
--resource_group_name=*)
1414
resource_group_name="${i#*=}"
15-
shift
15+
shift
1616
;;
1717
--nginx_deployment_name=*)
1818
nginx_deployment_name="${i#*=}"
19-
shift
19+
shift
2020
;;
2121
--config_dir_path=*)
2222
config_dir_path="${i#*=}"
23-
shift
23+
shift
2424
;;
2525
--root_config_file=*)
2626
root_config_file="${i#*=}"
27-
shift
27+
shift
2828
;;
2929
--transformed_config_dir_path=*)
3030
transformed_config_dir_path="${i#*=}"
31-
shift
31+
shift
32+
;;
33+
--debug=*)
34+
debug="${i#*=}"
35+
shift
3236
;;
3337
*)
3438
echo "Not matched option '${i#*=}' passed in."
@@ -40,27 +44,27 @@ done
4044
if [[ ! -v subscription_id ]];
4145
then
4246
echo "Please set 'subscription-id' ..."
43-
exit 1
47+
exit 1
4448
fi
4549
if [[ ! -v resource_group_name ]];
4650
then
4751
echo "Please set 'resource-group-name' ..."
48-
exit 1
52+
exit 1
4953
fi
5054
if [[ ! -v nginx_deployment_name ]];
5155
then
5256
echo "Please set 'nginx-deployment-name' ..."
53-
exit 1
57+
exit 1
5458
fi
5559
if [[ ! -v config_dir_path ]];
5660
then
5761
echo "Please set 'nginx-config-directory-path' ..."
58-
exit 1
62+
exit 1
5963
fi
6064
if [[ ! -v root_config_file ]];
6165
then
6266
echo "Please set 'nginx-root-config-file' ..."
63-
exit 1
67+
exit 1
6468
fi
6569

6670
# Validation and preprocessing
@@ -78,7 +82,7 @@ fi
7882
if [[ -d "$config_dir_path" ]]
7983
then
8084
echo "The NGINX configuration directory '$config_dir_path' was found."
81-
else
85+
else
8286
echo "The NGINX configuration directory '$config_dir_path' does not exist."
8387
exit 1
8488
fi
@@ -96,7 +100,7 @@ root_config_file_repo_path="$config_dir_path$root_config_file"
96100
if [[ -f "$root_config_file_repo_path" ]]
97101
then
98102
echo "The root NGINX configuration file '$root_config_file_repo_path' was found."
99-
else
103+
else
100104
echo "The root NGINX configuration file '$root_config_file_repo_path' does not exist."
101105
exit 1
102106
fi
@@ -152,4 +156,25 @@ echo "ARM template deployment name: $template_deployment_name"
152156
echo ""
153157

154158
az account set -s "$subscription_id" --verbose
155-
az deployment group create --name "$template_deployment_name" --resource-group "$resource_group_name" --template-file "$template_file" --parameters nginxDeploymentName="$nginx_deployment_name" rootFile="$transformed_root_config_file_path" tarball="$encoded_config_tarball" --verbose
159+
160+
az_cmd=(
161+
"az"
162+
"deployment"
163+
"group"
164+
"create"
165+
"--name" "$template_deployment_name"
166+
"--resource-group" "$resource_group_name"
167+
"--template-file" "$template_file"
168+
"--parameters"
169+
"nginxDeploymentName=$nginx_deployment_name"
170+
"rootFile=$transformed_root_config_file_path"
171+
"tarball=$encoded_config_tarball"
172+
"--verbose"
173+
)
174+
175+
if [[ "$debug" == true ]]; then
176+
az_cmd+=("--debug")
177+
fi
178+
179+
echo "${az_cmd[@]}"
180+
"${az_cmd[@]}"

0 commit comments

Comments
 (0)