Skip to content

Commit

Permalink
Merge 4de5b66 into 1860b37
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCoderCarl authored Dec 1, 2022
2 parents 1860b37 + 4de5b66 commit 7e94806
Show file tree
Hide file tree
Showing 12 changed files with 695 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Code Quality

on:
push:
branches: [ feature/* ]

jobs:
code_quality:
runs-on: ubuntu-latest
name: Checks with black, isort
container: python:3.9

steps:

- name: Checkout code
uses: actions/checkout@v2

- name: Run script
run: pip install -r requirements.txt

- name: Black check
run: black --check .

- name: Isort check
run: isort --check .

- name: Step To run on failure
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
<b>!!! FAILED !!!</b>
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
38 changes: 38 additions & 0 deletions .github/workflows/ignore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Ignore and notify

on:
push:
branches:
- main
- develop
paths-ignore:
- 'README.md'
- '.gitignore'
- '.dockerignore'
- 'changelog.json'

jobs:

telegram:
runs-on: ubuntu-latest
name: Notify after update
steps:

- name: Notify after released image
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
${{ github.actor }} created commit:
<b>WorkFlows:</b> <a href="https://github.com/${{ github.repository }}/actions/">ActionsList</a>
Repository: ${{ github.repository }}
Branch: ${{ github.ref }}
<b>Something were changed</b>
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
112 changes: 112 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Publish

on:
pull_request:
branches: [ develop ]

jobs:

prepare:
name: Prepare env & label
runs-on: ubuntu-latest
outputs:
get_current_tag: ${{ steps.set_current_tag_id.outputs.current_tag }}

steps:

- name: Checkout code
uses: actions/checkout@v2

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.0
with:
github_token: ${{ secrets.REPOS_TOKEN }}

- name: Set label develop
uses: actions-ecosystem/action-add-labels@v1
with:
labels: develop

- name: Add author as assignees
uses: actions-ecosystem/action-add-assignees@v1
with:
assignees: ${{ github.actor }}
github_token: ${{ secrets.REPOS_TOKEN }}

- name: Set tag version to output
id: set_current_tag_id
run: echo "::set-output name=current_tag::${{ steps.tag_version.outputs.new_tag }}"

- name: Notify if failure
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
<b>!!! FAILED !!!</b>
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
docker:
runs-on: ubuntu-latest
needs: prepare
name: Publish on DockerHub

steps:

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Checkout code
uses: actions/checkout@v2

- name: Build and push
id: push_image
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Containerfile
tags: ${{ secrets.DOCKER_USERNAME }}/techpriest_bot:${{ needs.prepare.outputs.get_current_tag }}

- name: Step To run on failure
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
<b>!!! FAILED !!!</b>
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
- name: Notify in telegram after image was pushed
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
${{ github.actor }} created commit:
<b>WorkFlows:</b> <a href="https://github.com/${{ github.repository }}/actions">ActionsList</a>
Commit with tag: ${{ needs.prepare.outputs.get_current_tag }}
Repository: ${{ github.repository }}
Branch: ${{ github.ref }}
<b>Pushed image:</b> <code>docker pull ${{ secrets.DOCKER_USERNAME }}/techpriest_bot:${{ needs.prepare.outputs.get_current_tag }}</code>
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
121 changes: 121 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Release

on:
pull_request:
branches: [ main ]

jobs:

prepare:
name: Prepare env & label
runs-on: ubuntu-latest
outputs:
get_current_tag: ${{ steps.set_current_tag_id.outputs.current_tag }}

steps:

- name: Checkout code
uses: actions/checkout@v2

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.0
with:
github_token: ${{ secrets.REPOS_TOKEN }}

- name: Set label release
uses: actions-ecosystem/action-add-labels@v1
with:
labels: release

- name: Add author as assignees
uses: actions-ecosystem/action-add-assignees@v1
with:
assignees: ${{ github.actor }}
github_token: ${{ secrets.REPOS_TOKEN }}

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

- name: Set tag version to output
id: set_current_tag_id
run: echo "::set-output name=current_tag::${{ steps.tag_version.outputs.new_tag }}"

- name: Notify if failure
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
<b>!!! FAILED !!!</b>
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
docker:
runs-on: ubuntu-latest
needs: prepare
name: Publish on DockerHub

steps:

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Checkout code
uses: actions/checkout@v2

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Containerfile
tags: ${{ secrets.DOCKER_USERNAME }}/techpriest_bot:latest

- name: Notify if failure
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
<b>!!! FAILED !!!</b>
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
telegram:
runs-on: ubuntu-latest
name: Notification
needs: [docker, prepare]

steps:
- name: Notify telegram message after Released
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
${{ github.actor }} created commit:
<b>WorkFlows:</b> <a href="https://github.com/${{ github.repository }}/actions">ActionsList</a>
Commit with tag: ${{ needs.prepare.outputs.get_current_tag }}
Repository: ${{ github.repository }}
Branch: ${{ github.ref }}
<b>Pushed image:</b> <code>docker pull ${{ secrets.DOCKER_USERNAME }}/techpriest_bot:latest</code>
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ dmypy.json

# Pyre type checker
.pyre/

# Secret file
settings.toml

# Session journals
*.session*

# Search scheme
search_*.txt
14 changes: 14 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.9-alpine as builder

WORKDIR /opt

COPY ["bot.py", "/opt/"]
COPY ["mongodb.py", "/opt/"]
COPY ["dynaconfig.py", "/opt/"]
COPY requirements.txt requirements.txt

RUN pip3 install --no-cache-dir -r requirements.txt

FROM builder

CMD ["python3", "/opt/bot.py"]
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
drestart: dstop dstart

dstart:
echo "Starting docker-compose deattahced"
docker-compose up -d

dstop:
echo "Stopping docker-compose"
docker-compose down

dclear:
echo "Prune docker system"
docker system prune -f
Loading

0 comments on commit 7e94806

Please sign in to comment.