From 39e2eb0c649f405702530872214bc9689c824939 Mon Sep 17 00:00:00 2001 From: Hafiz Adewuyi Date: Mon, 5 Aug 2024 20:02:10 +0300 Subject: [PATCH] Fix multiline issue with the shell script. (#76) --- .github/workflows/api-deploy-staging.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/api-deploy-staging.yml b/.github/workflows/api-deploy-staging.yml index 83e74d3..546935f 100644 --- a/.github/workflows/api-deploy-staging.yml +++ b/.github/workflows/api-deploy-staging.yml @@ -33,13 +33,15 @@ jobs: echo "$SSH_PRIVATE_KEY" > private_key chmod 600 private_key rsync -avz --exclude 'appsettings.json' -e "ssh -i private_key -o StrictHostKeyChecking=no" out/ ec2-user@$EC2_INSTANCE_IP:$SERVICE_PATH - ssh -i private_key -o StrictHostKeyChecking=no ec2-user@$EC2_INSTANCE_IP ' - sudo systemctl restart $SERVICE_NAME - sleep 3 - STATUS=$(sudo systemctl is-active $SERVICE_NAME) - if [ "$STATUS" != "active" ]; then - sudo systemctl status $SERVICE_NAME --no-pager - exit 1 - fi - ' + ssh -i private_key -o StrictHostKeyChecking=no ec2-user@$EC2_INSTANCE_IP " + sudo systemctl restart $SERVICE_NAME + sleep 1 + STATUS=\$(sudo systemctl is-active $SERVICE_NAME) + if [ '\$STATUS\' != 'active' ]; then + sudo systemctl status $SERVICE_NAME --no-pager + exit 1 + else + echo 'Service was restarted successfully.' + fi + " shell: bash