From 5efe1ea0b6fad116ec15dea7ab0b10c3619ad881 Mon Sep 17 00:00:00 2001 From: LuckyHunter Date: Sat, 18 Feb 2023 23:51:30 +0800 Subject: [PATCH] restructure the folder --- .github/workflows/{docker-builder.yml => build.yml} | 4 ++-- .github/workflows/{docker-run.yml => checkin.yml} | 4 ++-- README.md | 12 ++++++++++-- .dockerignore => app/.dockerignore | 0 Dockerfile => app/Dockerfile | 0 {config => app/config}/config_example.toml | 0 main.py => app/main.py | 2 +- {notify => app/notify}/notify.py | 0 requirements.txt => app/requirements.txt | 0 scheduler.py => app/scheduler.py | 0 {utils => app/utils}/file_helper.py | 0 11 files changed, 15 insertions(+), 7 deletions(-) rename .github/workflows/{docker-builder.yml => build.yml} (97%) rename .github/workflows/{docker-run.yml => checkin.yml} (90%) rename .dockerignore => app/.dockerignore (100%) rename Dockerfile => app/Dockerfile (100%) rename {config => app/config}/config_example.toml (100%) rename main.py => app/main.py (98%) rename {notify => app/notify}/notify.py (100%) rename requirements.txt => app/requirements.txt (100%) rename scheduler.py => app/scheduler.py (100%) rename {utils => app/utils}/file_helper.py (100%) diff --git a/.github/workflows/docker-builder.yml b/.github/workflows/build.yml similarity index 97% rename from .github/workflows/docker-builder.yml rename to .github/workflows/build.yml index 291574d..749449a 100644 --- a/.github/workflows/docker-builder.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Docker image release +name: Build image on: workflow_dispatch: @@ -40,7 +40,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v4 with: - context: . + context: app platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 push: true tags: ${{ steps.string.outputs.lowercase }}:latest diff --git a/.github/workflows/docker-run.yml b/.github/workflows/checkin.yml similarity index 90% rename from .github/workflows/docker-run.yml rename to .github/workflows/checkin.yml index d5340e3..059ab3a 100644 --- a/.github/workflows/docker-run.yml +++ b/.github/workflows/checkin.yml @@ -1,9 +1,9 @@ -name: SMZDM Check-in Docker Bot +name: Check in on: workflow_dispatch: workflow_run: - workflows: ["Docker image release"] + workflows: ["Build image"] types: - completed diff --git a/README.md b/README.md index b667484..74578cb 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ **务必自行更改为随机时间** 1. Fork[此仓库项目](https://github.com/Chasing66/smzdm_bot)>, 欢迎`star`~ -2. 修改 `.github/workflows/docker-run.yml`里的下面部分, 取消`schedule`两行的注释,自行设定时间 +2. 修改 `.github/workflows/checkin.yml`里的下面部分, 取消`schedule`两行的注释,自行设定时间 ```yaml # UTC时间,对应Beijing时间 9:30 @@ -40,7 +40,15 @@ schedule: ### 2.2 本地运行 -复制`config/config_example.toml`为`config/config.toml`,并按照需求配置 +复制`app/config/config_example.toml`为`app/config/config.toml`,并按照需求配置 + +```bash +python3 -m venv .venv +source .venv/bin/activate +cd app +pip install -r requirements.txt +python main.py +``` ### 2.3 本地 docker 运行 diff --git a/.dockerignore b/app/.dockerignore similarity index 100% rename from .dockerignore rename to app/.dockerignore diff --git a/Dockerfile b/app/Dockerfile similarity index 100% rename from Dockerfile rename to app/Dockerfile diff --git a/config/config_example.toml b/app/config/config_example.toml similarity index 100% rename from config/config_example.toml rename to app/config/config_example.toml diff --git a/main.py b/app/main.py similarity index 98% rename from main.py rename to app/main.py index bfe658d..bf5b92a 100644 --- a/main.py +++ b/app/main.py @@ -92,7 +92,7 @@ def main(): if Path.exists(Path(CONFIG_PATH, "config.toml")): logger.info("Get configration from config.toml") conf_kwargs = TomlHelper(Path(CONFIG_PATH, "config.toml")).read() - elif os.environ.get("ANDROID_COOKIES", None): + elif os.environ.get("ANDROID_COOKIE", None): logger.info("Get configration from env") conf_kwargs = { "USER_AGENT": os.environ.get("USER_AGENT"), diff --git a/notify/notify.py b/app/notify/notify.py similarity index 100% rename from notify/notify.py rename to app/notify/notify.py diff --git a/requirements.txt b/app/requirements.txt similarity index 100% rename from requirements.txt rename to app/requirements.txt diff --git a/scheduler.py b/app/scheduler.py similarity index 100% rename from scheduler.py rename to app/scheduler.py diff --git a/utils/file_helper.py b/app/utils/file_helper.py similarity index 100% rename from utils/file_helper.py rename to app/utils/file_helper.py