Skip to content

Commit 14cc47c

Browse files
committed
remove azure pipeline task from the actions repo
The Azure Pipeline task currently resides in the GitHub Actions repository, but this structure does not follow GitHub's guidelines for publishing actions. As a result, the autogenerated action documentation provides incorrect usage instructions (e.g., suggesting uses: nginxinc/nginx-for-azure-deploy-action@v0.4.0), which fails because the action is located in a subdirectory.
1 parent a625b59 commit 14cc47c

40 files changed

+188
-1007
lines changed

.github/workflows/azure-pipeline-build.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

README.md

Lines changed: 188 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,200 @@
1-
# NGINXaaS for Azure Configuration Automation
1+
# NGINXaaS for Azure Deployment Action
22

3-
This repository hosts two essential projects that facilitate the management and deployment of NGINXaaS for Azure configurations. Both projects aim to automate the process of synchronizing NGINX configuration files, but they target different platforms and have unique features and notation. To learn more about NGINXaaS for Azure, please review the [product homepage](https://www.nginx.com/products/nginx/nginxaas-for-azure/).
3+
This action supports managing the configuration of an [NGINXaaS for Azure](https://docs.nginx.com/nginxaas/azure/quickstart/overview/) deployment in a GitHub repository. It enables continuous deployment through GitHub workflows to automatically update the NGINXaaS for Azure deployment when changes are made to the NGINX configuration files stored in the repository. Additionally, one can update NGINX certificates that are already present in Azure key vault.
44

5-
## Projects
5+
## Connecting to Azure
66

7-
### 1. Azure Pipeline Task
7+
This action leverages the [Azure Login](https://github.com/marketplace/actions/azure-login) action for authenticating with Azure and performing update to an NGINXaaS 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 an Azure service principal using a Federated Identity Credential
810

9-
This project provides a custom Azure pipeline task that automates the synchronization of NGINXaaS configuration files for Azure deployments. It supports both GitHub Action pipelines and Azure DevOps pipeline tasks. [Read more](./azure-pipeline/README.md).
11+
### Sample workflow that authenticates with Azure using an Azure service principal with a secret
1012

11-
### 2. GitHub Action Task
13+
```yaml
14+
# File: .github/workflows/nginxForAzureDeploy.yml
1215

13-
This GitHub Action enables continuous deployment through GitHub workflows to automatically update the NGINXaaS for Azure deployment when changes are made to the NGINX configuration files stored in the repository. It also supports updating NGINX certificates that are present in Azure key vault. [Read more](./github-action/README.md).
16+
name: Sync the NGINX configuration from the GitHub repository to an NGINXaaS for Azure deployment
17+
on:
18+
push:
19+
branches:
20+
- main
21+
paths:
22+
- config/**
1423

15-
## Comparison
24+
jobs:
25+
Deploy-NGINX-Configuration:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: 'Checkout repository'
29+
uses: actions/checkout@v2
1630

17-
| Feature/Aspect | Azure Pipeline Task | GitHub Action Task |
18-
|------------------------------------|------------------------------------|-------------------------------------|
19-
| **CI/CD Automation** | Yes | Yes |
20-
| **Configuration File Host** | GitHub Repos or Azure Repos | GitHub |
21-
| **Security** | Pipelines in secured agents | Azure Login Action |
22-
| **Authentication Methods** | Service Connection | Service Principal with Secrets, OIDC|
23-
| **Certificate Handling** | No | Yes (Azure key vault) |
24-
| **CI/CD Platform** | Azure DevOps | GitHub |
31+
- name: 'Run Azure Login using an Azure service principal with a secret'
32+
uses: azure/login@v2
33+
with:
34+
creds: ${{ secrets.AZURE_CREDENTIALS }}
2535

26-
## Getting Started
36+
- name: 'Sync the NGINX configuration from the GitHub repository to the NGINXaaS for Azure deployment'
37+
uses: nginxinc/nginx-for-azure-deploy-action/github-action@v0.4.0
38+
with:
39+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
40+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
41+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
42+
nginx-config-directory-path: config/
43+
nginx-root-config-file: nginx.conf
44+
transformed-nginx-config-directory-path: /etc/nginx/
45+
debug: false
46+
```
2747
28-
To get started with either of these projects, please refer to the detailed README files linked above.
48+
### Sample workflow that authenticates with Azure using OIDC
2949
30-
## License
50+
```yaml
51+
# File: .github/workflows/nginxForAzureDeploy.yml
3152

32-
These projects are licensed under the Apache-2.0 License - see the [LICENSE.md](LICENSE) file for details.
53+
name: Sync the NGINX configuration from the GitHub repository to an NGINXaaS for Azure deployment
54+
on:
55+
push:
56+
branches:
57+
- main
58+
paths:
59+
- config/**
60+
61+
permissions:
62+
id-token: write
63+
contents: read
64+
65+
jobs:
66+
Deploy-NGINX-Configuration:
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: 'Checkout repository'
70+
uses: actions/checkout@v2
71+
72+
- name: 'Run Azure Login using OIDC'
73+
uses: azure/login@v2
74+
with:
75+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
76+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
77+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
78+
79+
- name: 'Sync the NGINX configuration from the GitHub repository to the NGINXaaS for Azure deployment'
80+
uses: nginxinc/nginx-for-azure-deploy-action/github-action@v0.4.0
81+
with:
82+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
83+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
84+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
85+
nginx-config-directory-path: config/
86+
nginx-root-config-file: nginx.conf
87+
transformed-nginx-config-directory-path: /etc/nginx/
88+
debug: false
89+
```
90+
91+
> **Note:**
92+
The service principal being used for authenticating with Azure should have access to manage the NGINXaaS deployment. For simplicity, this guide assumes that the service principal has `Contributor` role to manage the deployment. Refer [prerequisites](https://docs.nginx.com/nginxaas/azure/getting-started/prerequisites/) for details.
93+
94+
## Handling NGINX configuration file paths
95+
96+
To facilitate the migration of the existing NGINX configuration, NGINXaaS 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/).
97+
98+
The following example shows two NGINX configuration files inside the `/etc/nginx` directory on disk are copied and stored in a GitHub repository under its `config` directory.
99+
100+
| File path on disk | File path in the repository |
101+
| ------------------------------------ | --------------------------------- |
102+
| /etc/nginx/nginx.conf | /config/nginx.conf |
103+
| /etc/nginx/sites-enabled/mysite.conf | /config/sites-enabled/mysite.conf |
104+
105+
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`.
106+
107+
```yaml
108+
- name: 'Sync the NGINX configuration from the GitHub repository to the NGINXaaS for Azure deployment'
109+
uses: nginxinc/nginx-for-azure-deploy-action/github-action@v0.4.0
110+
with:
111+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
112+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
113+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
114+
nginx-config-directory-path: config/
115+
nginx-root-config-file: nginx.conf
116+
debug: false
117+
```
118+
119+
By default, the action uses a file's relative path to `nginx-config-directory-path` in the repository as the file path in the NGINXaaS for Azure deployment.
120+
121+
| File path on disk | File path in the repository | File path in the NGINXaaS for Azure deployment |
122+
| ------------------------------------ | --------------------------------- | ---------------------------------------------- |
123+
| /etc/nginx/nginx.conf | /config/nginx.conf | nginx.conf |
124+
| /etc/nginx/sites-enabled/mysite.conf | /config/sites-enabled/mysite.conf | sites-enabled/mysite.conf |
125+
126+
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:
127+
128+
```
129+
include sites-enabled/mysite.conf;
130+
```
131+
132+
For the case of using absolute paths in `include` directives, for example, if the root `nginx.conf` references `mysite.conf` using:
133+
134+
```
135+
include /etc/nginx/sites-enabled/mysite.conf;
136+
```
137+
138+
The action supports an optional input `transformed-nginx-config-directory-path` to transform the absolute path of the configuration directory in the NGINXaaS 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 NGINXaaS for Azure deployment.
139+
140+
```yaml
141+
- name: 'Sync the NGINX configuration from the Git repository to the NGINXaaS for Azure deployment'
142+
uses: nginxinc/nginx-for-azure-deploy-action/github-action@v0.4.0
143+
with:
144+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
145+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
146+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
147+
nginx-config-directory-path: config/
148+
nginx-root-config-file: nginx.conf
149+
transformed-nginx-config-directory-path: /etc/nginx/
150+
debug: false
151+
```
152+
The transformed paths of the two configuration files in the NGINXaaS for Azure deployment are summarized in the following table
153+
154+
| File path on disk | File path in the repository | File path in the NGINXaaS for Azure deployment |
155+
| ------------------------------------ | --------------------------------- | ---------------------------------------------- |
156+
| /etc/nginx/nginx.conf | /config/nginx.conf | /etc/nginx/nginx.conf |
157+
| /etc/nginx/sites-enabled/mysite.conf | /config/sites-enabled/mysite.conf | /etc/nginx/sites-enabled/mysite.conf |
158+
159+
## Handling NGINX certificates
160+
161+
Since certificates are secrets, it is assumed they are stored in Azure key vault. One can provide multiple certificate entries to the github action as an array of JSON objects with keys:
162+
163+
`certificateName`- A unique name for the certificate entry
164+
165+
`keyvaultSecret`- The secret ID for the certificate on Azure key vault
166+
167+
`certificateVirtualPath`- This path must match one or more ssl_certificate directive file arguments in your Nginx configuration; and must be unique between certificates within the same deployment
168+
169+
`keyVirtualPath`- This path must match one or more ssl_certificate_key directive file arguments in your Nginx configuration; and must be unique between certificates within the same deployment
170+
171+
See the example below
172+
173+
```yaml
174+
- name: "Sync NGINX certificates to NGINXaaS for Azure"
175+
uses: nginxinc/nginx-for-azure-deploy-action/github-action@v0.4.0
176+
with:
177+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
178+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
179+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
180+
nginx-deployment-location: ${{ secrets.NGINX_DEPLOYMENT_LOCATION }}
181+
nginx-certificates: '[{"certificateName": "$NGINX_CERT_NAME", "keyvaultSecret": "https://$NGINX_VAULT_NAME.vault.azure.net/secrets/$NGINX_CERT_NAME", "certificateVirtualPath": "/etc/nginx/ssl/my-cert.crt", "keyVirtualPath": "/etc/nginx/ssl/my-cert.key" } ]'
182+
debug: false
183+
```
184+
185+
## Handling NGINX configuration and certificates
186+
187+
```yaml
188+
- name: "Sync NGINX configuration- multi file and certificate to NGINXaaS for Azure"
189+
uses: nginxinc/nginx-for-azure-deploy-action/github-action@v0.4.0
190+
with:
191+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
192+
resource-group-name: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
193+
nginx-deployment-name: ${{ secrets.NGINX_DEPLOYMENT_NAME }}
194+
nginx-deployment-location: ${{ secrets.NGINX_DEPLOYMENT_LOCATION }}
195+
nginx-config-directory-path: config/
196+
nginx-root-config-file: nginx.conf
197+
transformed-nginx-config-directory-path: /etc/nginx/
198+
nginx-certificates: '[{"certificateName": "$NGINX_CERT_NAME", "keyvaultSecret": "https://$NGINX_VAULT_NAME.vault.azure.net/secrets/$NGINX_CERT_NAME", "certificateVirtualPath": "/etc/nginx/ssl/my-cert.crt", "keyVirtualPath": "/etc/nginx/ssl/my-cert.key" } ]'
199+
debug: false
200+
```
File renamed without changes.

azure-pipeline/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

azure-pipeline/example.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.
-5.63 KB
Binary file not shown.
-37 KB
Binary file not shown.
-82.7 KB
Binary file not shown.
-28.5 KB
Binary file not shown.
-30.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)