-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from KGBTR/refactor/overhaul
refactor: overhaul service after production release
- Loading branch information
Showing
10 changed files
with
73 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
NO_REPLY=True | ||
PYTHONUNBUFFERED=true | ||
BASE_LOG_DIR=logs | ||
PYTHONENV=development | ||
|
||
BOT_CLIENT_ID='<client_id>' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Release new version | ||
|
||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Copy service files via SSH password | ||
uses: appleboy/scp-action@v0.1.7 | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
source: "koyunotlatan/*,koyunotlatan/data/*,scripts/*,koyunotlatan.service,koyunotlatan.timer,koyunotlatan.pkla,praw.example.ini,requirements.txt,LICENSE,pyproject.toml" | ||
target: /home/koyunotlatan/service | ||
|
||
- name: Setup service via SSH | ||
uses: appleboy/ssh-action@v1.0.3 | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
script: | | ||
/home/koyunotlatan/service/scripts/release.sh | ||
# Fulfill credentials for praw.ini | ||
perl -pe 's/<username>/${{ secrets.PRAW_USERNAME }}/g; s/<password>/${{ secrets.PRAW_PASSWORD }}/g; s/<client_id>/${{ secrets.PRAW_CLIENT_ID }}/g; s/<client_secret>/${{ secrets.PRAW_CLIENT_SECRET }}/g' /home/koyunotlatan/service/praw.example.ini > /home/koyunotlatan/service/praw.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
export WORKDIR=/home/koyunotlatan/service | ||
|
||
# Set virtual enviroment directory as enviroment variable | ||
export VIRTUAL_ENV=$WORKDIR/.venv | ||
|
||
# Check $VIRTUAL_ENV enviroment variable exist | ||
if [[ -n "$VIRTUAL_ENV" ]]; then | ||
# Create virtual enviroment if not exist | ||
if [[ ! -d "$VIRTUAL_ENV" ]]; then | ||
python3 -m venv $VIRTUAL_ENV | ||
chown -R koyunotlatan_ci:koyunotlatan $VIRTUAL_ENV | ||
fi | ||
|
||
# Install dependencies with virtual enviroment | ||
$VIRTUAL_ENV/bin/pip install -r $WORKDIR/requirements.txt | ||
fi | ||
|
||
systemctl daemon-reload | ||
systemctl enable koyunotlatan.timer | ||
systemctl start koyunotlatan.timer | ||
systemctl start koyunotlatan.service |