From 4ccf40bf350b5735e8d6fd339c7f9adf99448444 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Mon, 4 Sep 2023 22:59:30 +0500 Subject: [PATCH] Allow better customisation of autodeploy through secrets and variables (#102) The production environment and host are ready for this PR Signed-off-by: Octol1ttle --- .github/workflows/build-push.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 731201d..36ae3de 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -21,7 +21,9 @@ jobs: uses: actions/checkout@v3 - name: Publish solution - run: dotnet publish -c Release -r linux-x64 --no-self-contained -p:PublishReadyToRun=true + run: dotnet publish $PUBLISH_FLAGS + env: + PUBLISH_FLAGS: ${{vars.PUBLISH_FLAGS}} - name: Setup SSH key run: | @@ -33,29 +35,30 @@ jobs: SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}} SSH_HOST: ${{secrets.SSH_HOST}} - - name: Quit currently running instance - continue-on-error: true + - name: Stop currently running instance run: | - ssh $SSH_USER@$SSH_HOST pkill --signal SIGQUIT Boyfriend + ssh $SSH_USER@$SSH_HOST $STOP_COMMAND shell: bash env: SSH_USER: ${{secrets.SSH_USER}} SSH_HOST: ${{secrets.SSH_HOST}} + STOP_COMMAND: ${{vars.STOP_COMMAND}} - name: Upload published solution run: | - scp -r bin/Release/net7.0/linux-x64/publish/* $SSH_USER@$SSH_HOST:$UPLOAD_DESTINATION + scp -r $UPLOAD_FROM $SSH_USER@$SSH_HOST:$UPLOAD_TO shell: bash env: SSH_USER: ${{secrets.SSH_USER}} SSH_HOST: ${{secrets.SSH_HOST}} - UPLOAD_DESTINATION: ${{secrets.UPLOAD_DESTINATION}} + UPLOAD_FROM: ${{vars.UPLOAD_FROM}} + UPLOAD_TO: ${{vars.UPLOAD_TO}} - - name: Start uploaded solution + - name: Start new instance run: | - ssh $SSH_USER@$SSH_HOST $COMMAND + ssh $SSH_USER@$SSH_HOST $START_COMMAND shell: bash env: SSH_USER: ${{secrets.SSH_USER}} SSH_HOST: ${{secrets.SSH_HOST}} - COMMAND: ${{secrets.COMMAND}} + START_COMMAND: ${{vars.START_COMMAND}}