Skip to content

Fix embed displays to look better #132

Fix embed displays to look better

Fix embed displays to look better #132

Workflow file for this run

name: Deploy Bot
on:
push:
branches:
- prod
workflow_dispatch:
inputs:
restart_bot:
description: 'Restart Bot'
required: true
type: boolean
concurrency:
group: "botdeploy"
cancel-in-progress: false
jobs:
cleanup:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Cleanup Previous Deployments
uses: strumwolf/delete-deployment-environment@v3
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: production
onlyRemoveDeployments: true
deploy:
needs: cleanup
environment: production
env:
AUTHKEYNAME: ${{ vars.AUTH_KEY_NAME }}
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Action Check
uses: dorny/[email protected]
id: filter
with:
base: ${{ github.ref }}
filters: |
deps_update_needed:
- 'requirements.txt'
core_updated:
- '**.py'
# Adding the Private key to a Github Actions Workflow
- name: Install SSH Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
log-public-key: false
# If any runtime files updated, then we need to stop all bot instances.
- name: Kill Instances
id: kill_bot
if: steps.filter.outputs.deps_update_needed == 'true' || steps.filter.outputs.core_updated == 'true' || inputs.restart_bot == 'true'
uses: appleboy/ssh-action@master
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{secrets.SSH_USERNAME}}
script: |
cd ~/project/AntiScamBot
.runtime/kill.sh
echo "Service Killed."
# We want to update the project regardless.
- name: Update Project
uses: appleboy/ssh-action@master
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{secrets.SSH_USERNAME}}
envs: AUTHKEYNAME
script: |
cd ~/project/AntiScamBot
echo "Setting SSH Agent"
eval "$(ssh-agent -s)"
echo "Readding SSH Key"
ssh-add ~/.ssh/$AUTHKEYNAME
echo "Checking Git Readability"
ssh -T [email protected]
echo "Updating directory"
git pull
echo "Deploy success"
- name: Update Python Dependencies
id: deps_update
if: steps.filter.outputs.deps_update_needed == 'true'
uses: appleboy/ssh-action@master
continue-on-error: false
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{secrets.SSH_USERNAME}}
script_stop: true
script: |
cd ~/project/AntiScamBot
.runtime/update.sh
echo "Finished updating python dependencies"
- name: Restart Instances
if: ${{ always() && (steps.deps_update.conclusion == 'success' || steps.deps_update.outcome == 'skipped') && steps.kill_bot.conclusion == 'success' }}
uses: appleboy/ssh-action@master
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{secrets.SSH_USERNAME}}
command_timeout: 5s
script_stop: false
script: |
echo "Restarting instances"
cd ~/project/AntiScamBot
nohup .runtime/run.sh &>/dev/null &