name: "Publish and deploy" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: push: branches: [ "master" ] jobs: upload-solution: name: Upload Boyfriend to production runs-on: ubuntu-latest permissions: actions: read contents: read environment: production steps: - name: Checkout repository uses: actions/checkout@v3 - name: Publish solution run: dotnet publish -c Release -r linux-x64 --no-self-contained -p:PublishReadyToRun=true - name: Setup SSH key run: | install -m 600 -D /dev/null ~/.ssh/id_rsa echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts shell: bash env: SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}} SSH_HOST: ${{secrets.SSH_HOST}} - name: Quit currently running instance continue-on-error: true run: | ssh $SSH_USER@$SSH_HOST pkill --signal SIGQUIT Boyfriend shell: bash env: SSH_USER: ${{secrets.SSH_USER}} SSH_HOST: ${{secrets.SSH_HOST}} - name: Upload published solution run: | scp -r bin/Release/net7.0/linux-x64/publish/* $SSH_USER@$SSH_HOST:$UPLOAD_DESTINATION shell: bash env: SSH_USER: ${{secrets.SSH_USER}} SSH_HOST: ${{secrets.SSH_HOST}} UPLOAD_DESTINATION: ${{secrets.UPLOAD_DESTINATION}} - name: Start uploaded solution run: | ssh $SSH_USER@$SSH_HOST $COMMAND shell: bash env: SSH_USER: ${{secrets.SSH_USER}} SSH_HOST: ${{secrets.SSH_HOST}} COMMAND: ${{secrets.COMMAND}}