From 26d8bdddcce232d63a082f577ce0a5f8eceb20e8 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 13 Apr 2024 02:19:20 -0500 Subject: [PATCH] chore: run script with correct privileges --- .github/workflows/deploy.yml | 2 +- scripts/deploy.ps1 | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 26c8f76..bdeb487 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,4 +67,4 @@ jobs: key: ${{ secrets.SSH_KEY }} script: | chmod +x blog.stevanfreeborn.com/deploy.ps1 - ./blog.stevanfreeborn.com/deploy.ps1 ${{ needs.build.outputs.version }} \ No newline at end of file + sudo pwsh ./blog.stevanfreeborn.com/deploy.ps1 ${{ needs.build.outputs.version }} \ No newline at end of file diff --git a/scripts/deploy.ps1 b/scripts/deploy.ps1 index fb4085d..e7fb054 100644 --- a/scripts/deploy.ps1 +++ b/scripts/deploy.ps1 @@ -1,5 +1,3 @@ -#!/bin/pwsh - $NGINX_CONFIG_PATH = "/etc/nginx/sites-available/blog.ddnsgeek.com" function StartContainer { @@ -108,6 +106,8 @@ if ($LASTEXITCODE -ne 0) # Checkif green container is running $greenContainerId = docker ps --filter "name=blog.stevanfreeborn.com.green" --format "{{.ID}}" +Write-Host "Green container ID: $greenContainerId" + if ($null -eq $greenContainerId) { Write-Host "Green container is running. Starting blue container." @@ -120,7 +120,7 @@ if ($null -eq $greenContainerId) Write-Host "Nginx configuration updated to point to blue container on port $blueContainerHostPort." - sudo nginx -t + nginx -t if ($LASTEXITCODE -ne 0) { @@ -129,7 +129,7 @@ if ($null -eq $greenContainerId) exit 1 } - sudo nginx -s reload + nginx -s reload if ($LASTEXITCODE -ne 0) { @@ -185,7 +185,7 @@ else Write-Host "Nginx configuration updated to point to green container on port $greenContainerHostPort." - sudo nginx -t + nginx -t if ($LASTEXITCODE -ne 0) { @@ -194,7 +194,7 @@ else exit 1 } - sudo nginx -s reload + nginx -s reload if ($LASTEXITCODE -ne 0) {