Skip to content

Commit 514937e

Browse files
authored
Merge pull request #16 from nginxinc/bangbingsyb/update-readme
Prepare for action publishing - update readme and use the ARM template from the specified commit
2 parents 806ac52 + c39aabf commit 514937e

File tree

2 files changed

+68
-4
lines changed

2 files changed

+68
-4
lines changed

README.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# NGINX for Azure Deployment Action
22

3-
This action syncs NGINX configuration files in the repository to an NGINX deployment in Azure. It enables continuous deployment scenarios where the configuration of the NGINX deployment is automatically updated when changes are made through GitHub workflows.
3+
This action supports managing the configuration of an an [NGINX for Azure](https://docs.nginx.com/nginx-for-azure/quickstart/overview/) deployment in a GitHub repository. It enables continuous deployment through GitHub workflows to automatically update the NGINX for Azure deployment when changes are made to the NGINX configuration files stored in the respository.
44

5-
## Usage example
5+
## Connecting to Azure
66

7-
The following example updates the configuration of a NGINX deployment in Azure each time a change is made to the configuration file in config folder in the `main` branch.
7+
This action leverages the [Azure Login](https://github.com/marketplace/actions/azure-login) action for authenticating with Azure and performing update to an NGINX for Azure deployment. Two different ways of authentication are supported:
8+
- [Service principal with secrets](https://docs.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Cwindows#use-the-azure-login-action-with-a-service-principal-secret)
9+
- [OpenID Connect](https://docs.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Cwindows#use-the-azure-login-action-with-openid-connect) (OIDC) with a Azure service principal using a Federated Identity Credential
810

911
### Sample workflow that authenticates with Azure using Azure Service Principal with a secret
1012

@@ -83,3 +85,65 @@ jobs:
8385
nginx-root-config-file: nginx.conf
8486
transformed-nginx-config-directory-path: /etc/nginx/
8587
```
88+
## Handling NGINX configuration file paths
89+
90+
To facilitate the migration of the existing NGINX configuration, NGINX for Azure supports multiple-files configuration with each file uniquely identified by a file path, just like how NGINX configuration files are created and used in a self-hosting machine. An NGINX configuration file can include another file using the [include directive](https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/). The file path used in an include directive can either be an absolute path or a relative path to the [prefix path](https://www.nginx.com/resources/wiki/start/topics/tutorials/installoptions/).
91+
92+
The following example shows two NGINX configuration files inside the `/etc/nginx` directory on disk are copied and stored in the a GitHub respository under its `config` directory.
93+
94+
| File path on disk | File path in respository |
95+
|--------------------------------------|-----------------------------------|
96+
| /etc/nginx/nginx.conf | /config/nginx.conf |
97+
| /etc/nginx/sites-enabled/mysite.conf | /config/sites-enabled/mysite.conf |
98+
99+
To use this action to sync the configuration files from this example, the directory path relative to the GitHub repository root `config/` is set to the action's input `nginx-config-directory-path` for the action to find and package the configuration files. The root file `nginx.conf` is set to the input `nginx-root-config-file`.
100+
101+
```yaml
102+
- name: 'Sync the NGINX configuration from the Git repository to the NGINX for Azure deployment'
103+
uses: nginxinc/nginx-for-azure-deploy-action@v1
104+
with:
105+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
106+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
107+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
108+
nginx-config-directory-path: config/
109+
nginx-root-config-file: nginx.conf
110+
```
111+
112+
By default, the action uses a file's relative path to `nginx-config-directory-path` in the respository as the file path in the NGINX for Azure deployment.
113+
114+
| File path on disk | File path in respository | File path in NGINX for Azure |
115+
|--------------------------------------|-----------------------------------|------------------------------|
116+
| /etc/nginx/nginx.conf | /config/nginx.conf | nginx.conf |
117+
| /etc/nginx/sites-enabled/mysite.conf | /config/sites-enabled/mysite.conf | sites-enabled/mysite.conf |
118+
119+
The default file path handling works for the case of using relative paths in `include` directives, for example, if the root `nginx.conf` references `mysite.conf` using:
120+
121+
```
122+
include sites-enabled/mysite.conf;
123+
```
124+
125+
For the case of using absolute paths in `include` directives, for example, if the root `nginx.conf` references `mysite.conf` using:
126+
127+
```
128+
include /etc/nginx/sites-enabled/mysite.conf;
129+
```
130+
131+
The action supports an optional input `transformed-nginx-config-directory-path` to transform the absolute path of the configuration directory in the NGINX for Azure deployment. The absolute configuration directory path on disk `/etc/nginx/` can be set to `transformed-nginx-config-directory-path` as follows to ensure the configuration files using absolute paths in `include` directives work as expected in the NGINX for Azure deployment.
132+
133+
```yaml
134+
- name: 'Sync the NGINX configuration from the Git repository to the NGINX for Azure deployment'
135+
uses: nginxinc/nginx-for-azure-deploy-action@v1
136+
with:
137+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
138+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
139+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
140+
nginx-config-directory-path: config/
141+
nginx-root-config-file: nginx.conf
142+
transformed-nginx-config-directory-path: /etc/nginx/
143+
```
144+
The transformed paths of the two configuration files in the NGINX for Azure deployment are summarized in the following table
145+
146+
| File path on disk | File path in respository | File path in NGINX for Azure |
147+
|--------------------------------------|-----------------------------------|--------------------------------------|
148+
| /etc/nginx/nginx.conf | /config/nginx.conf | /etc/nginx/nginx.conf |
149+
| /etc/nginx/sites-enabled/mysite.conf | /config/sites-enabled/mysite.conf | /etc/nginx/sites-enabled/mysite.conf |

src/deploy-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ uuid="$(cat /proc/sys/kernel/random/uuid)"
8585
template_file="template-$uuid.json"
8686
template_deployment_name="${nginx_deployment_name:0:20}-$uuid"
8787

88-
wget -O "$template_file" https://raw.githubusercontent.com/nginxinc/nginx-for-azure-deploy-action/main/src/nginx-for-azure-configuration-template.json
88+
wget -O "$template_file" https://raw.githubusercontent.com/nginxinc/nginx-for-azure-deploy-action/487d1394d6115d4f42ece6200cbd20859595557d/src/nginx-for-azure-configuration-template.json
8989
echo "Downloaded the ARM template for synchronizing NGINX configuration."
9090
cat "$template_file"
9191
echo ""

0 commit comments

Comments
 (0)