From 420d5dcf11c399949c448c9c13faf209bafc2faf Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 17:02:52 +0100 Subject: [PATCH] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 45 ++++++++++-------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index 764c069..5d215a6 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,47 +1,30 @@ -name: Setup Nginx from the configuration file +name: Deploy Nginx Configuration on: - workflow_dispatch: # Manual trigger for the workflow + push: + branches: + - main + paths: + - "nginx/nginx.conf" # Adjust the path to your nginx.conf file in the root directory jobs: deploy: - runs-on: self-hosted # Ensure your runner is self-hosted + runs-on: self-hosted # Make sure your runner is self-hosted (or adjust this for GitHub-hosted runners) steps: - - name: Checkout repository - uses: actions/checkout@v3 + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v4 - # Optionally set environment variables (skip if not needed) - - 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 - - # Copy Nginx configuration to the server - - name: Copy Nginx configuration to server + # Copy Nginx Configuration to the server's /etc/nginx directory + - name: Copy Nginx Configuration run: | - sudo cp ./nginx_securefit.conf /etc/nginx/conf.d/nginx_securefit.conf - - # Test the Nginx configuration for errors + sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx_securefit.conf + # Test Nginx configuration to check for syntax errors - name: Test Nginx Configuration run: | sudo nginx -t - # Reload Nginx to apply the new configuration - name: Reload Nginx run: | sudo systemctl reload nginx - - # Check if Nginx is running properly - - name: Check Nginx status - run: | - sudo systemctl status nginx - - # Optionally, display the deployed Nginx configuration for debugging - - name: Show deployed Nginx configuration - run: | - cat /etc/nginx/conf.d/nginx_securefit.conf