From bebd06b9d163f5ab96904c00490ded186cbfc33c Mon Sep 17 00:00:00 2001 From: Ann-Marie Aeronuwy Francoise Revillard Date: Tue, 18 Mar 2025 13:31:36 +0100 Subject: [PATCH] Update update_primary_nginx.yml --- .github/workflows/update_primary_nginx.yml | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 9d2a24a..762c022 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -13,17 +13,38 @@ jobs: with: export-variables: true keys-case: bypass + - name: Check environment variables run: env + # - name: Check environment variables + # run: env - - + - name: Debug: Print Environment Variables + run: | + env | grep DEV_ || echo "No DEV_ variables found" - name: Set environment variables run: | echo "DEV_PORT_PREFIX=80" >> $GITHUB_ENV echo "STAG_PORT_PREFIX=443" >> $GITHUB_ENV echo "GATEWAY_POSTFIX=" >> $GITHUB_ENV - + - name: Verify environment variables + run: cat $GITHUB_ENV + + - name: Generate Nginx configuration + run: cat ./nginx_template.txt | envsubst > temp_default.conf + + - name: Show generated Nginx configuration + run: cat temp_default.conf + + - name: Copy Nginx config to the correct location + run: sudo cp temp_default.conf /etc/nginx/conf.d/default.conf + + - name: Test NGINX Configuration + run: sudo nginx -t + + - name: Restart NGINX + run: sudo systemctl reload nginx + #Doesn't work properly, envsubst replaces all instances of $variable and ${variable}, but we want to keep e.g., $host as nginx variables #- name: Create temporary nginx config file # run: envsubst < ./nginx_template.txt > temp_default.conf @@ -31,13 +52,26 @@ jobs: - name: Create temporary nginx config file run: envsubst '$REPLACE_ME $ANOTHER_VAR' < ./nginx_template.txt > temp_default.conf + # - name: Create temporary nginx config file + # run: envsubst '$REPLACE_ME $ANOTHER_VAR' < ./nginx_template.txt > temp_default.conf - name: Copy temporary file to correct place run: sudo cp temp_default.conf /etc/nginx/conf.d/default.conf + # - name: Copy temporary file to correct place + # run: sudo cp temp_default.conf /etc/nginx/conf.d/default.conf #added sudo here + - name: Show nginx file run: cat /etc/nginx/conf.d/default.conf + # - name: Show nginx file + # run: cat /etc/nginx/conf.d/default.conf + - name: Test NGINX Configuration run: sudo nginx -t + # - name: Test NGINX Configuration + # run: sudo nginx -t + - name: Restart NGINX run: sudo systemctl reload nginx + # - name: Restart NGINX + # run: sudo systemctl reload nginx