6
6
- cron : " 0 20 * * *"
7
7
8
8
env :
9
- NGINX_DEPLOYMENT_NAME : github-action-test-dep
10
- NGINX_TRANSFORMED_CONFIG_DIR_PATH : /etc/nginx/
11
- NGINX_ROOT_CONFIG_FILE : nginx.conf
12
- TEST_RESOURCE_GROUP_NAME : testenv-0da38993-workload
9
+ NGINX_CONFIG_DIRECTORY : github-action/test/configs
10
+ NGINX_DEPLOYMENT_NAME : n4a-long-westcent-nginxaas
11
+ NGINX_TRANSFORMED_CONFIG_DIR_PATH : /
12
+ NGINX_ROOT_CONFIG_FILE : /etc/nginx/nginx.conf
13
+ TEST_RESOURCE_GROUP_NAME : n4a-long-westcent-workload
13
14
NGINX_CERT_NAME : github-action-test-crt
14
15
NGINX_VAULT_NAME : nlbtest-customer
15
16
@@ -18,64 +19,73 @@ permissions:
18
19
contents : read
19
20
20
21
jobs :
22
+ Fetch-NGINX-State :
23
+ runs-on : ubuntu-latest
24
+ steps :
25
+ - name : " AZ CLI Login"
26
+ uses : azure/login@v1
27
+ with :
28
+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
29
+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
30
+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
31
+
32
+ - name : " Fetch deployment state"
33
+ uses : azure/CLI@v1
34
+ with :
35
+ azcliversion : 2.40.0
36
+ inlineScript : |
37
+ az extension add --source https://azcliprod.blob.core.windows.net/cli-extensions/nginx-0.1.1-py2.py3-none-any.whl -y
38
+ az nginx deployment show -g $TEST_RESOURCE_GROUP_NAME -n $NGINX_DEPLOYMENT_NAME --output json > nginx.json
39
+ az nginx deployment configuration show -g $TEST_RESOURCE_GROUP_NAME --deployment-name $NGINX_DEPLOYMENT_NAME -n default --output json > nginx.config.json
40
+ name : nginx-state
41
+ path : |
42
+ nginx.json
43
+ nginx.config.json
44
+
21
45
Update-NGINX :
22
46
runs-on : ubuntu-latest
23
47
steps :
24
- - name : " Checkout repository"
25
- uses : actions/checkout@v2
26
- - name : " AZ CLI Login"
27
- uses : azure/login@v1
28
- with :
29
- client-id : ${{ secrets.AZURE_CLIENT_ID }}
30
- tenant-id : ${{ secrets.AZURE_TENANT_ID }}
31
- subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
48
+ - name : " Checkout repository"
49
+ uses : actions/checkout@v2
50
+
51
+ - name : " AZ CLI Login"
52
+ uses : azure/login@v1
53
+ with :
54
+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
55
+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
56
+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
32
57
33
- - name : " Update config - single file"
34
- shell : bash
35
- run : |
36
- sed -i 's/000000/'"$GITHUB_RUN_NUMBER"'/g' github-action/test/configs/single/nginx.conf
37
- cat github-action/test/configs/single/nginx.conf
38
- - name : " Sync NGINX configuration to NGINXaaS for Azure - single file"
39
- uses : nginxinc/nginx-for-azure-deploy-action@v0.3.1
40
- with :
41
- subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
42
- resource-group-name : $TEST_RESOURCE_GROUP_NAME
43
- nginx-deployment-name : $NGINX_DEPLOYMENT_NAME
44
- nginx-config-directory-path : github-action/test/configs/single/
45
- nginx-root-config-file : $NGINX_ROOT_CONFIG_FILE
46
- transformed-nginx-config-directory-path : $NGINX_TRANSFORMED_CONFIG_DIR_PATH
47
- - name : " Validate config update - single file"
48
- shell : bash
49
- run : |
50
- wget -O - -o /dev/null http://${{ secrets.NGINX_DEPLOYMENT_IP }} | jq '.request.headers."Github-Run-Id" | test( "'"$GITHUB_RUN_NUMBER"'")'
51
- - name : " Update config - multi file"
52
- shell : bash
53
- run : |
54
- sed -i 's/000000/'"$GITHUB_RUN_ID"'/g' github-action/test/configs/multi/nginx.conf
55
- cat github-action/test/configs/multi/nginx.conf
56
- sed -i 's/000000/'"$GITHUB_RUN_ID"'/g' github-action/test/configs/multi/conf.d/proxy.conf
57
- cat github-action/test/configs/multi/conf.d/proxy.conf
58
- - name : " Sync NGINX configuration and certificate to NGINXaaS for Azure - multi file"
59
- uses : nginxinc/nginx-for-azure-deploy-action@v0.3.1
60
- with :
61
- subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
62
- resource-group-name : $TEST_RESOURCE_GROUP_NAME
63
- nginx-deployment-name : $NGINX_DEPLOYMENT_NAME
64
- nginx-deployment-location : " westcentralus"
65
- nginx-config-directory-path : github-action/test/configs/multi/
66
- nginx-root-config-file : $NGINX_ROOT_CONFIG_FILE
67
- transformed-nginx-config-directory-path : $NGINX_TRANSFORMED_CONFIG_DIR_PATH
68
- nginx-certificates : ' [{"certificateName": "$NGINX_CERT_NAME", "keyvaultSecret": "https://$NGINX_VAULT_NAME.vault.azure.net/secrets/$NGINX_CERT_NAME", "certificateVirtualPath": "/etc/nginx/ssl/$GITHUB_RUN_ID/my-cert.crt", "keyVirtualPath": "/etc/nginx/ssl/$GITHUB_RUN_ID/my-cert.key" } ]'
58
+ - name : Download math result for job 1
59
+ uses : actions/download-artifact@v4
60
+ with :
61
+ name : nginx-state
69
62
70
- - name : " Validate config update"
71
- shell : bash
72
- run : |
73
- wget -O - -o /dev/null http://${{ secrets.NGINX_DEPLOYMENT_IP }} | jq '.request.headers."Github-Run-Id" | test( "'"$GITHUB_RUN_ID"'")'
74
- - name : " Validate certificate update"
75
- uses : azure/CLI@v1
76
- with :
77
- inlineScript : |
78
- echo "-----BEGIN CERTIFICATE-----" > /tmp/$GITHUB_RUN_ID.tmp
79
- az keyvault certificate show --vault-name $NGINX_VAULT_NAME -n $NGINX_CERT_NAME | jq -r .cer | cat >> /tmp/$GITHUB_RUN_ID.tmp
80
- echo "-----END CERTIFICATE-----" >> /tmp/$GITHUB_RUN_ID.tmp
81
- 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"'")'
63
+ - name : " Prep Config Files"
64
+ shell : bash
65
+ run : |
66
+ ./github-action/test/scripts/config_to_files.sh -f $PWD/nginx.config.json -o $NGINX_CONFIG_DIRECTORY
67
+ sed -i 's/000000/'"$GITHUB_RUN_ID"'/g' $NGINX_CONFIG_DIRECTORY/github_action.conf
68
+ mv $NGINX_CONFIG_DIRECTORY/github_action.conf $NGINX_CONFIG_DIRECTORY/etc/nginx/conf.d/servers/github_action.conf
69
+ cat $NGINX_CONFIG_DIRECTORY/etc/nginx/conf.d/servers/github_action.conf
70
+ - name : " Sync NGINX configuration and certificate to NGINXaaS for Azure"
71
+ uses : nginxinc/nginx-for-azure-deploy-action@v0.3.1
72
+ with :
73
+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
74
+ resource-group-name : $TEST_RESOURCE_GROUP_NAME
75
+ nginx-deployment-name : $NGINX_DEPLOYMENT_NAME
76
+ nginx-deployment-location : " westcentralus"
77
+ nginx-config-directory-path : $NGINX_CONFIG_DIRECTORY
78
+ nginx-root-config-file : $NGINX_ROOT_CONFIG_FILE
79
+ transformed-nginx-config-directory-path : $NGINX_TRANSFORMED_CONFIG_DIR_PATH
80
+ nginx-certificates : ' [{"certificateName": "$NGINX_CERT_NAME", "keyvaultSecret": "https://$NGINX_VAULT_NAME.vault.azure.net/secrets/$NGINX_CERT_NAME", "certificateVirtualPath": "/etc/nginx/ssl/$GITHUB_RUN_ID/my-cert.crt", "keyVirtualPath": "/etc/nginx/ssl/$GITHUB_RUN_ID/my-cert.key" } ]'
81
+
82
+ - name : " Validate certificate and config update"
83
+ uses : azure/CLI@v1
84
+ with :
85
+ inlineScript : |
86
+ export NGINX_DEPLOYMENT_IP=$(cat nginx.json | jq '.properties.ipAddress')
87
+ wget -O - -o /dev/null http://${{ NGINX_DEPLOYMENT_IP }}/github-action | grep '$GITHUB_RUN_ID'
88
+ echo "-----BEGIN CERTIFICATE-----" > /tmp/$GITHUB_RUN_ID.tmp
89
+ az keyvault certificate show --vault-name $NGINX_VAULT_NAME -n $NGINX_CERT_NAME | jq -r .cer | cat >> /tmp/$GITHUB_RUN_ID.tmp
90
+ echo "-----END CERTIFICATE-----" >> /tmp/$GITHUB_RUN_ID.tmp
91
+ wget -O - -o /dev/null https://${{ NGINX_DEPLOYMENT_IP }}:8443/github-action --ca-certificate=/tmp/$GITHUB_RUN_ID.tmp | grep '$GITHUB_RUN_ID'
0 commit comments