Deploy nginx configuration to TDT4242 server #23
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: Set up environment variables | |
| uses: falti/dotenv-action@v1.1.4 | |
| with: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Check environment variables | |
| run: env | |
| - name: Check if sudo is working without a password | |
| run: | | |
| sudo whoami | |
| # Copying nginx configuration file to the server | |
| - name: Deploy nginx configuration file | |
| run: | | |
| sudo envsubst < ./nginx_secfit.conf | sudo tee /etc/nginx/conf.d/nginx.conf > /dev/null | |
| # Test the nginx configuration | |
| - name: Test nginx configuration file | |
| run: | | |
| sudo nginx -t | |
| # Restarting nginx service | |
| - name: Restart nginx service | |
| run: | | |
| sudo systemctl restart nginx | |
| - name: Show deployed configuration | |
| run: | | |
| cat /etc/nginx/conf.d/nginx.conf |