Skip to content

Commit baefb0e

Browse files
committed
Update root file path handling
1 parent 63b6f44 commit baefb0e

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
3838
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
3939
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
40-
nginx-config-directory-path: config
41-
nginx-root-config-file-name: nginx.conf
42-
transformed-nginx-config-directory-path: /etc/nginx
40+
nginx-config-directory-path: config/
41+
nginx-root-config-file: nginx.conf
42+
transformed-nginx-config-directory-path: /etc/nginx/
4343
```
4444
4545
### Sample workflow that authenticates with Azure using OIDC
@@ -79,7 +79,7 @@ jobs:
7979
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
8080
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
8181
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
82-
nginx-config-directory-path: config
83-
nginx-root-config-file-name: nginx.conf
84-
transformed-nginx-config-directory-path: /etc/nginx
82+
nginx-config-directory-path: config/
83+
nginx-root-config-file: nginx.conf
84+
transformed-nginx-config-directory-path: /etc/nginx/
8585
```

action.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ inputs:
1111
description: 'The name of the NGINX for Azure deployment.'
1212
required: true
1313
nginx-config-directory-path:
14-
description: 'The NGINX configuration directory path relative to the root of the Git repository, example: "config".'
14+
description: 'The NGINX configuration directory path relative to the root of the Git repository, example: "config/".'
1515
required: true
16-
nginx-root-config-file-name:
16+
nginx-root-config-file:
1717
description: >
18-
'The root NGINX configuration file name, example: "nginx.conf". The root file must be in the NGINX configuration directory
19-
but not in its subdirectory.'
18+
'The root NGINX configuration file path relative to the NGINX configuration directory in the Git repository, example: "nginx.conf".'
2019
required: false
2120
default: 'nginx.conf'
2221
transformed-nginx-config-directory-path:
2322
description: >
24-
'The transformed absolute path of the NGINX configuration directory in NGINX for Azure deployment, example: "/etc/nginx".
23+
'The transformed absolute path of the NGINX configuration directory in NGINX for Azure deployment, example: "/etc/nginx/".
2524
If the "include" directive in the NGINX configuration files uses absolute paths, the path transformation
2625
can be used to overwrite the file paths when the action synchronizes the files to the NGINX for Azure deployment.'
2726
required: false
@@ -30,5 +29,5 @@ runs:
3029
using: "composite"
3130
steps:
3231
- name: 'Synchronize NGINX configuration from the Git repository to an NGINX for Azure deployment'
33-
run: ${{github.action_path}}/src/deploy-config.sh ${{ inputs.subscription-id }} ${{ inputs.resource-group-name }} ${{ inputs.nginx-deployment-name }} ${{ inputs.nginx-config-directory-path }} ${{ inputs.nginx-root-config-file-name }} ${{ inputs.transformed-nginx-config-directory-path }}
32+
run: ${{github.action_path}}/src/deploy-config.sh ${{ inputs.subscription-id }} ${{ inputs.resource-group-name }} ${{ inputs.nginx-deployment-name }} ${{ inputs.nginx-config-directory-path }} ${{ inputs.nginx-root-config-file }} ${{ inputs.transformed-nginx-config-directory-path }}
3433
shell: bash

src/deploy-config.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ subscription_id=$1
66
resource_group_name=$2
77
nginx_deployment_name=$3
88
config_dir_path=$4
9-
root_config_file_name=$5
9+
root_config_file=$5
1010
transformed_config_dir_path=${6:-''}
1111

1212
# Validation and preprocessing
1313

1414
if [[ "$config_dir_path" = /* ]]
1515
then
1616
echo "The NGINX configuration directory path in the repository '$config_dir_path' must be a relative path."
17-
exit 2
17+
exit 1
1818
elif [[ ! "$config_dir_path" = */ ]]
1919
then
2020
echo "The NGINX configuration directory path '$config_dir_path' does not end with '/'. Appending a trailing '/'."
@@ -26,32 +26,40 @@ then
2626
echo "The NGINX configuration directory '$config_dir_path' was found."
2727
else
2828
echo "The NGINX configuration directory '$config_dir_path' does not exist."
29-
exit 2
29+
exit 1
3030
fi
3131

32-
root_config_file_path="$config_dir_path$root_config_file_name"
33-
if [[ -f "$root_config_file_path" ]]
32+
if [[ "$root_config_file" = /* ]]
3433
then
35-
echo "The root NGINX configuration file '$root_config_file_path' was found."
34+
echo "The NGINX configuration root file path '$root_config_file' must be a relative path to the NGINX configuration directory."
35+
exit 1
36+
fi
37+
38+
root_config_file=$(echo $root_config_file | sed 's:^\.\/*::')
39+
40+
root_config_file_repo_path="$config_dir_path$root_config_file"
41+
if [[ -f "$root_config_file_repo_path" ]]
42+
then
43+
echo "The root NGINX configuration file '$root_config_file_repo_path' was found."
3644
else
37-
echo "The root NGINX configuration file '$root_config_file_path' does not exist."
38-
exit 2
45+
echo "The root NGINX configuration file '$root_config_file_repo_path' does not exist."
46+
exit 1
3947
fi
4048

4149
if [[ -n "$transformed_config_dir_path" ]]
4250
then
4351
if [[ ! "$transformed_config_dir_path" = /* ]]
4452
then
4553
echo "The specified transformed NGINX configuration directory path '$transformed_config_dir_path' must be an absolute path that starts with '/'."
46-
exit 2
54+
exit 1
4755
elif [[ ! "$transformed_config_dir_path" = */ ]]
4856
then
4957
echo "The specified transformed NGINX configuration directory path '$transformed_config_dir_path' does not end with '/'. Appending a trailing '/'."
5058
transformed_config_dir_path="$transformed_config_dir_path/"
5159
fi
5260
fi
5361

54-
transformed_root_config_file_path="$transformed_config_dir_path$root_config_file_name"
62+
transformed_root_config_file_path="$transformed_config_dir_path$root_config_file"
5563
echo "The transformed root NGINX configuration file path is '$transformed_root_config_file_path'."
5664

5765
# Create a NGINX configuration tarball.

0 commit comments

Comments
 (0)