Skip to content

Commit 320d85f

Browse files
committed
Updated test workflow to verify certificate update process
1 parent 9313a85 commit 320d85f

File tree

2 files changed

+52
-15
lines changed

2 files changed

+52
-15
lines changed

.github/workflows/testNginxForAzureDeploy.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,87 @@
33
name: Test Github action to update NGINX for Azure configurations
44
on:
55
schedule:
6-
- cron: '0 20 * * *'
6+
- cron: "0 20 * * *"
77

88
env:
99
NGINX_DEPLOYMENT_NAME: github-action-test-dep
1010
NGINX_TRANSFORMED_CONFIG_DIR_PATH: /etc/nginx/
1111
NGINX_ROOT_CONFIG_FILE: nginx.conf
1212
TEST_RESOURCE_GROUP_NAME: testenv-0da38993-workload
13+
NGINX_CERT_NAME: github-action-test-crt
14+
NGINX_VAULT_NAME: nlbtest-customer
1315

1416
permissions:
1517
id-token: write
1618
contents: read
1719

1820
jobs:
19-
Update-NGINX-Configuration:
21+
Update-NGINX:
2022
runs-on: ubuntu-latest
2123
steps:
22-
- name: 'Checkout repository'
24+
- name: "Checkout repository"
2325
uses: actions/checkout@v2
24-
- name: 'AZ CLI Login'
26+
- name: "AZ CLI Login"
2527
uses: azure/login@v1
2628
with:
27-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
28-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
29-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
30-
- name: 'Update config - single file'
29+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
30+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
31+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
32+
- name: "Sync NGINX Certificate to NGINX on Azure instance - single cert"
33+
uses: nginxinc/[email protected]
34+
with:
35+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
36+
resource-group-name: $TEST_RESOURCE_GROUP_NAME
37+
nginx-deployment-name: $NGINX_DEPLOYMENT_NAME
38+
nginx-certificate-details: '[{"certificateName": "$NGINX_CERT_NAME", "keyvaultSecret": "https://$NGINX_VAULT_NAME.vault.azure.net/secrets/$NGINX_CERT_NAME", "certificateVirtualPath": "/etc/nginx/ssl/$GITHUB_RUN_NUMBER/my-cert.crt", "keyVirtualPath": "/etc/nginx/ssl/$GITHUB_RUN_NUMBER/my-cert.key" } ]'
39+
40+
- name: "Update config - single file"
3141
shell: bash
3242
run: |
3343
sed -i 's/000000/'"$GITHUB_RUN_NUMBER"'/g' test/configs/single/nginx.conf
3444
cat test/configs/single/nginx.conf
35-
- name: 'Sync NGINX configuration to NGINX on Azure instance - single file'
36-
uses: nginxinc/nginx-for-azure-deploy-action@v0
45+
- name: "Sync NGINX configuration to NGINX on Azure instance - single file"
46+
uses: nginxinc/nginx-for-azure-deploy-action@v0.2.0
3747
with:
3848
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
3949
resource-group-name: $TEST_RESOURCE_GROUP_NAME
4050
nginx-deployment-name: $NGINX_DEPLOYMENT_NAME
4151
nginx-config-directory-path: test/configs/single/
4252
nginx-root-config-file: $NGINX_ROOT_CONFIG_FILE
4353
transformed-nginx-config-directory-path: $NGINX_TRANSFORMED_CONFIG_DIR_PATH
44-
- name: 'Validate config update - single file'
54+
- name: "Validate config update - single file"
4555
shell: bash
4656
run: |
4757
wget -O - -o /dev/null http://${{ secrets.NGINX_DEPLOYMENT_IP }} | jq '.request.headers."Github-Run-Id" | test( "'"$GITHUB_RUN_NUMBER"'")'
48-
- name: 'Update config - multi file'
58+
- name: "Update config - multi file"
4959
shell: bash
5060
run: |
61+
sed -i 's/000000/'"$GITHUB_RUN_ID"'/g' test/configs/multi/nginx.conf
62+
cat test/configs/single/nginx.conf
5163
sed -i 's/000000/'"$GITHUB_RUN_ID"'/g' test/configs/multi/conf.d/proxy.conf
5264
cat test/configs/multi/conf.d/proxy.conf
53-
- name: 'Sync NGINX configuration to NGINX on Azure instance - multi file'
54-
uses: nginxinc/nginx-for-azure-deploy-action@v0
65+
- name: "Sync NGINX configuration to NGINX on Azure instance - multi file"
66+
uses: nginxinc/nginx-for-azure-deploy-action@v0.2.0
5567
with:
5668
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
5769
resource-group-name: $TEST_RESOURCE_GROUP_NAME
5870
nginx-deployment-name: $NGINX_DEPLOYMENT_NAME
5971
nginx-config-directory-path: test/configs/multi/
6072
nginx-root-config-file: $NGINX_ROOT_CONFIG_FILE
6173
transformed-nginx-config-directory-path: $NGINX_TRANSFORMED_CONFIG_DIR_PATH
62-
- name: 'Validate config update'
74+
75+
- name: "Validate config update"
6376
shell: bash
6477
run: |
6578
wget -O - -o /dev/null http://${{ secrets.NGINX_DEPLOYMENT_IP }} | jq '.request.headers."Github-Run-Id" | test( "'"$GITHUB_RUN_ID"'")'
79+
- name: "Create cert file"
80+
uses: azure/CLI@v1
81+
with:
82+
inlineScript: |
83+
echo "-----BEGIN CERTIFICATE-----" > /tmp/$GITHUB_RUN_ID.tmp
84+
az keyvault certificate show --vault-name $NGINX_VAULT_NAME -n $NGINX_CERT_NAME | jq -r .cer | cat >> /tmp/$GITHUB_RUN_ID.tmp
85+
echo "-----END CERTIFICATE-----" >> /tmp/$GITHUB_RUN_ID.tmp
86+
- name: "Validate certificate update"
87+
shell: bash
88+
run: |
89+
wget -O - -o /dev/null https://${{ secrets.NGINX_DEPLOYMENT_IP }} --ca-certificate=/tmp/$GITHUB_RUN_ID.tmp | jq '.request.headers."Github-Run-Id" | test( "'"$GITHUB_RUN_ID"'")'

test/configs/multi/nginx.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ http {
1414
proxy_pass http://app;
1515
health_check;
1616
}
17+
}
18+
19+
server {
20+
listen 443 ssl default_server;
21+
server_name example.com;
1722

23+
ssl_certificate /etc/nginx/ssl/000000/my-cert.crt;
24+
ssl_certificate_key /etc/nginx/ssl/000000/my-cert.key;
25+
26+
location / {
27+
include /etc/nginx/conf.d/proxy.conf;
28+
proxy_pass http://app;
29+
health_check;
30+
}
1831
}
1932
}

0 commit comments

Comments
 (0)