Try again please #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy nginx configuration to TDT4242 server | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| deploy-nginx: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Export environment variables | |
| run: | | |
| export URL_PREFIX=http:// | |
| export PORT_PREFIX=2 | |
| export DEV_POSTFIX=1 | |
| export STAG_POSTFIX=2 | |
| export PROD_POSTFIX=3 | |
| export DEV_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${DEV_POSTFIX} | |
| export STAG_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${STAG_POSTFIX} | |
| export PROD_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX} | |
| - name: Replace environment variables in Nginx config | |
| run: | | |
| envsubst < nginx_template > nginx.conf | |
| # Test the nginx configuration | |
| - name: Test nginx configuration file | |
| run: | | |
| sudo nginx -t | |
| # Copying nginx configuration file to the server | |
| - name: Deploy nginx configuration file | |
| run: | | |
| sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf | |
| # Restarting nginx service | |
| - name: Restart nginx service | |
| run: | | |
| sudo systemctl restart nginx | |
| - name: Show deployed configuration | |
| run: | | |
| cat /etc/nginx/conf.d/nginx.conf |