Skip to content

Setup nginx from the configuration file #1

Setup nginx from the configuration file

Setup nginx from the configuration file #1

name: Setup NGINX from the configuration file
on:
workflow_dispatch:
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Load environment variables
uses: falti/dotenv-action@v1.1.4
with:
export-variables: true
keys-case: bypass
- name: Check environment variables
run: env
- name: Create temporary nginx config file
run: |
# Define the list of variables to replace
VARIABLES_TO_REPLACE="BACKEND_HOST FRONTEND_HOST GATEWAY_PORT"
# Use envsubst to replace only the specified variables
envsubst "$VARIABLES_TO_REPLACE" < ./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: Show nginx file
run: cat /etc/nginx/conf.d/default.conf
- name: Reload NGINX
run: sudo nginx -s reload