1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

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>
This commit is contained in:
Octol1ttle 2023-08-14 18:24:20 +05:00 committed by GitHub
parent da2a88246c
commit 501c51b865
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 36 deletions

View file

@ -1760,3 +1760,7 @@ resharper_zero_index_from_end_highlighting = warning
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
tab_width = 4 tab_width = 4
[*.yml]
indent_style = space
indent_size = 2

31
.github/workflows/build-pr.yml vendored Normal file
View file

@ -0,0 +1,31 @@
name: "ReSharper"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches: [ "master" ]
merge_group:
types: [ checks_requested ]
jobs:
inspect-code:
name: Inspect code
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: ReSharper CLI InspectCode
uses: muno92/resharper_inspectcode@1.8.0
with:
solutionPath: ./Boyfriend.sln
ignoreIssueType: InvertIf, ConvertIfStatementToSwitchStatement
extensions: ReSharperPlugin.CognitiveComplexity
solutionWideAnalysis: true

61
.github/workflows/build-push.yml vendored Normal file
View file

@ -0,0 +1,61 @@
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}}

View file

@ -1,36 +0,0 @@
name: "ReSharper"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "master" ]
merge_group:
types: [checks_requested]
jobs:
inspect-code:
name: Inspect code
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore dependencies and tools
run: dotnet restore
- name: ReSharper CLI InspectCode
uses: muno92/resharper_inspectcode@1.8.0
with:
solutionPath: ./Boyfriend.sln
ignoreIssueType: InvertIf, ConvertIfStatementToSwitchStatement
extensions: ReSharperPlugin.CognitiveComplexity
solutionWideAnalysis: true