Skip to content

Update reddit.py

Update reddit.py #22

Workflow file for this run

name: Deploy
on:
push:
# branches:
# - develop
# - dev
branches:
- master
- main
- "releases/**"
- "!releases/**-alpha"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d_%H_%M_%S')" >> $GITHUB_OUTPUT
- name: Create env file
uses: DamianReeves/write-file-action@master
with:
path: ".env"
contents: |
API_ID=${{ secrets.API_ID }}
API_HASH=${{ secrets.API_HASH }}
BOT_TOKEN=${{ secrets.BOT_TOKEN }}
PHONE=${{ secrets.PHONE }}
DATABASE_URL=${{ secrets.DATABASE_URL }}
LOCALE=ru
REDIS_URL=${{ secrets.REDIS_URL }}
REDDIT_ID=${{ secrets.REDDIT_ID }}
REDDIT_SECRET=${{ secrets.REDDIT_SECRET }}
REDDIT_TOKEN=${{ secrets.REDDIT_TOKEN }}
write-mode: overwrite
- name: Replace systemd unit file
run: |
sed -i 's|$REMOTE_TARGET|${{ secrets.REMOTE_TARGET }}|g' deadwood-bot.service
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i --delete"
SOURCE: "./"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/venv/, /.venv/, /.git/, /.github/"
SCRIPT_BEFORE: |
sudo systemctl stop deadwood-bot.service
sudo systemctl disable deadwood-bot.service
sudo systemctl daemon-reload
sudo chown -R ${{ secrets.REMOTE_USER }} ${{ secrets.REMOTE_TARGET }}
tar --exclude='${{ secrets.REMOTE_TARGET }}/venv' -zcvf ~/deadwood-bot_backup_${{ steps.date.outputs.date }}.tgz ${{ secrets.REMOTE_TARGET }}
SCRIPT_AFTER: |
chmod 0777 ${{ secrets.REMOTE_TARGET }}/data
python3 -m venv ${{ secrets.REMOTE_TARGET }}/venv
cd ${{ secrets.REMOTE_TARGET }} && . ./venv/bin/activate && \
pip install -r requirements.txt && aerich upgrade && \
pip install babel && \
pybabel compile -f -d ${{ secrets.REMOTE_TARGET }}/locales
sudo ln -s ${{ secrets.REMOTE_TARGET }}/deadwood-bot.service /etc/systemd/system/deadwood-bot.service
sudo chown -R nobody:nogroup ${{ secrets.REMOTE_TARGET }}
sudo systemctl daemon-reload
sudo systemctl enable deadwood-bot.service
sudo systemctl start deadwood-bot.service