Skip to content

Commit

Permalink
Update update_primary_nginx.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
amrevill authored and GitHub Enterprise committed Mar 18, 2025
1 parent 1c490d7 commit 6053f5f
Showing 1 changed file with 4 additions and 46 deletions.
50 changes: 4 additions & 46 deletions .github/workflows/update_primary_nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,20 @@ jobs:

- 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
# Maybe look at https://www.baeldung.com/linux/envsubst-command to get an idea

########## ja
- 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

run: envsubst '$http_host, $remote_addr, $proxy_add_x_forwarded_for' < ./nginx_template.txt > temp_default.conf
#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

0 comments on commit 6053f5f

Please sign in to comment.