This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
OctobotStealth/.github/workflows/build-push.yml
Octol1ttle 501c51b865
Add automatic deployment (#90)
This PR closes #87.

This PR splits the workflow into 2 files: `build-pr.yml` and
`build-push.yml`.
The former runs InspectCode to make sure issues don't get through, while
the latter builds and uploads Boyfriend and publishes it to a remote
production server via SSH.

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-08-14 13:24:20 +00:00

61 lines
1.7 KiB
YAML

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}}