فهرست منبع

ci(github-actions): add github actions

metya 2 سال پیش
والد
کامیت
a68b0216ed
9فایلهای تغییر یافته به همراه50 افزوده شده و 9 حذف شده
  1. 2 1
      .dockerignore
  2. 1 1
      .github/dependabot.yaml
  3. 3 3
      .github/workflows/bumpversion.yml
  4. 32 0
      .github/workflows/deploy.yml
  5. 1 1
      .pre-commit-config.yaml
  6. 1 0
      Dockerfile
  7. 1 0
      config.py
  8. 1 0
      docker-compose.yaml
  9. 8 3
      vanitybot.py

+ 2 - 1
.dockerignore

@@ -1,3 +1,4 @@
 geckodriver
 *.ipynb
-*.log
+*.log
+token

+ 1 - 1
.github-not_work_yet/dependabot.yaml → .github/dependabot.yaml

@@ -19,4 +19,4 @@ updates:
     allow:
       - dependency-type: "all"
     commit-message:
-      prefix: ":arrow_up:" v
+      prefix: ":arrow_up:"

+ 3 - 3
.github-not_work_yet/workflows/bumpversion.yml → .github/workflows/bumpversion.yml

@@ -12,11 +12,11 @@ jobs:
     name: "Bump version and create changelog with commitizen"
     steps:
       - name: Check out
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
-          token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
+          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
           fetch-depth: 0
       - name: Create bump and changelog
         uses: commitizen-tools/commitizen-action@master
         with:
-          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

+ 32 - 0
.github/workflows/deploy.yml

@@ -0,0 +1,32 @@
+name: Deploy bot with docker-compose
+
+on:
+  push:
+    branches:
+      - master
+    tags:
+      - v1.*
+
+jobs:
+  deploy-bot:
+    runs-on: ubuntu-latest
+    name: Deploy Vanity Bot
+    env:
+      API_TOKEN: ${{ secrets.API_TOKEN }}
+    steps:
+      - name: Check out
+        uses: actions/checkout@v3
+      - name: RUN ECHO
+        run: echo $API_TOKEN
+      - name: Deploy compose
+        uses: wshihadeh/docker-deployment-action@v2
+        # env:
+        #   API_TOKEN: ${ { secrets.API_TOKEN } }
+        with:
+          remote_docker_host: ${{ secrets.REMOTE_HOST }}
+          ssh_private_key: ${{ secrets.PRIVATE_KEY }}
+          ssh_public_key: ${{ secrets.PUBLIC_KEY }}
+          deployment_mode: docker-compose
+          args: up -d
+          docker_prune: "false"
+          pull_images_first: "false"

+ 1 - 1
.pre-commit-config.yaml

@@ -4,4 +4,4 @@ repos:
     stages:
     - commit-msg
   repo: https://github.com/commitizen-tools/commitizen
-  rev: v2.40.0
+  rev: v2.42.1

+ 1 - 0
Dockerfile

@@ -5,6 +5,7 @@ ENV PIP_NO_CACHE_DIR=off \
 ARG API_TOKEN
 ENV API_TOKEN=$API_TOKEN
 
+RUN echo $API_TOKEN
 RUN apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev curl
 RUN apk add --no-cache git git-lfs
 

+ 1 - 0
config.py

@@ -6,6 +6,7 @@ if env_var := dotenv_values('token'):
 else:
     API_TOKEN = getenv("API_TOKEN")
 
+print(API_TOKEN)
 
 if __name__ == "__main__":
     print(API_TOKEN)

+ 1 - 0
docker-compose.yaml

@@ -2,6 +2,7 @@ version: "3.7"
 services:
   bot:
     build: .
+    # image: vanity
     environment:
       - API_TOKEN
     restart: always

+ 8 - 3
vanitybot.py

@@ -22,6 +22,9 @@ I'll send you back snippet of paper and arxiv-vanity.com mobile friendly link!\n
 Or add me to chat and I'll be watching the arxiv link and \
 reply to them with fancy arxiv-vanity links."
 
+async def deploy_message():
+    await bot.send_message(chat_id=1147194, text='The deployment has been performed')
+
 @dp.message_handler(commands=['start'])
 async def process_start_command(message: types.Message):
     await message.reply(help_message)
@@ -46,7 +49,7 @@ async def vanitify(message: types.Message, dialog_manager: DialogManager):
         await manager.start(state=state, mode=mode, data=data)
 
     async def get_paper_abs(id_):
-        reply_message = f"[Here you can read the paper in mobile friendly way](https://www.arxiv-vanity.com/papers/{id_})"
+        reply_message = f"[Here you maybe can read the paper in mobile friendly way](https://www.arxiv-vanity.com/papers/{id_})"
         data = {
             "id": id_,
             "reply_message": reply_message,
@@ -76,6 +79,8 @@ async def vanitify(message: types.Message, dialog_manager: DialogManager):
 
 if __name__ == "__main__":
     logging.basicConfig(level=logging.INFO)
-    logging.getLogger("asyncio").setLevel(logging.DEBUG)
-    logging.getLogger("aiogram_dialog").setLevel(logging.DEBUG)
+    # logging.getLogger("asyncio").setLevel(logging.DEBUG)
+    # logging.getLogger("aiogram_dialog").setLevel(logging.DEBUG)
+
+    asyncio.get_event_loop().run_until_complete(deploy_message())
     executor.start_polling(dp, skip_updates=True)