Skip to content

Commit

Permalink
Add some operation stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
TyVik committed Jun 16, 2024
1 parent 1fecad3 commit 9529ad6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 38 deletions.
60 changes: 22 additions & 38 deletions .github/workflows/ci-cd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install PDM
Expand All @@ -30,9 +30,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install PDM
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Install dependencies using PDM
run: |
pdm install --dev
- name: Run tests
- name: Run linters
run: |
pdm run flake8
Expand All @@ -51,7 +51,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
Expand All @@ -65,11 +65,22 @@ jobs:
push: true
tags: krddev/bot:$GITHUB_REF_TYPE

# - name: Run tests
# run: |
# echo "Running tests.."
# pdm run pytest
#
deploy:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Add SSH key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Deploy
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} << 'EOF'
docker pull docker.io/krddev/bot:$GITHUB_REF_TYPE
sudo systemctl restart krddevbot.service
EOF
# - name: Add SSH key
# uses: webfactory/ssh-agent@v0.5.3
# with:
Expand All @@ -83,33 +94,6 @@ jobs:
# run: |
# ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "cat /home/${{ secrets.SERVER_USER }}/tasks/cicd/.env" > .env
#
# - name: Load secrets
# run: |
# export $(cat .env | xargs)
# echo "DOCKER_USERNAME=$(grep DOCKER_USERNAME .env | cut -d '=' -f2)" >> $GITHUB_ENV
# echo "DOCKER_PASSWORD=$(grep DOCKER_PASSWORD .env | cut -d '=' -f2)" >> $GITHUB_ENV
#
# - name: Lint with flake8
# run: |
# pdm run flake8 .
#
# - name: Build Podman image
# run: |
# podman build -t docker.io/drozdovnikolai/telegram-bot:${{ github.sha }} .
# podman tag docker.io/drozdovnikolai/telegram-bot:${{ github.sha }} docker.io/drozdovnikolai/telegram-bot:latest
#
# - name: Login to DockerHub
# env:
# DOCKER_USERNAME: ${{ env.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ env.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | podman login docker.io -u $DOCKER_USERNAME --password-stdin
#
# - name: Push Podman image
# run: |
# podman push docker.io/drozdovnikolai/telegram-bot:${{ github.sha }}
# podman push docker.io/drozdovnikolai/telegram-bot:latest
#
#
# deploy:
# needs: build-and-test
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

services:
krddevbot:
image: krddev/bot:main
container_name: krddevbot
restart: always
volumes:
- ~/krddevbot/tander:/app/tander
env_file:
- ~/krddevbot/.env
15 changes: 15 additions & 0 deletions krddevbot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=KrdDevBot systemd service
PartOf=docker.service
After=docker.service

[Service]
Type=oneshot
User=krddev
RemainAfterExit=true
WorkingDirectory=/home/krddev/
ExecStart=docker compose up -d --remove-orphans
ExecStop=docker compose down

[Install]
WantedBy=multi-user.target

0 comments on commit 9529ad6

Please sign in to comment.