diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 9733e17..b87a887 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -1,4 +1,4 @@ -name: UNFINISHED - setup nginx from the configuration file +name: Deploy Nginx Configuration on: workflow_dispatch: @@ -8,24 +8,36 @@ jobs: runs-on: self-hosted steps: - - name: Checkout repository + - name: Checkout Repository uses: actions/checkout@v3 - - name: Dotenv Action + + - name: Load Environment Variables uses: falti/dotenv-action@v1.1.4 with: export-variables: true keys-case: bypass - - name: Check environment variables + - name: Check Environment Variables run: env - #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 - - - name: Copy temporary file to correct place - run: cp temp_default.conf /etc/nginx/conf.d/default.conf + - name: Generate Nginx Config with Environment Variables + run: envsubst '${PROD_PORT_PREFIX} ${DEV_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_securefit.conf + + - name: Show Generated Nginx Config (Before Deploy) + run: cat nginx_securefit.conf + + - name: Validate Nginx Configuration (Before Deploy) + run: sudo nginx -t - - name: Show nginx file + - name: Copy Nginx Config to Server + run: | + sudo cp nginx_securefit.conf /etc/nginx/conf.d/nginx_securefit.conf + + - name: Show Deployed Nginx Config run: cat /etc/nginx/conf.d/default.conf + + - name: Restart Nginx + run: sudo systemctl reload nginx + + - name: Verify Nginx Status + run: sudo systemctl status nginx \ No newline at end of file diff --git a/README.md b/README.md index 2861241..3dce3ce 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # SecFit - SecFit (Secure Fitness) is a hybrid mobile application for fitness logging. ## Port mapping shenanigans