diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 890666a..eac633f 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,66 +1,18 @@ -name: Docker - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. +name: Docker Image CI on: push: - branches: [master] - # Publish semver tags as releases. - tags: ["v*.*.*"] + branches: [ "master" ] pull_request: - branches: [master] - -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} + branches: [ "master" ] jobs: + build: + runs-on: ubuntu-latest - permissions: - contents: read - packages: write steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) diff --git a/src/db_controller.rs b/src/db_controller.rs index 30c09ea..8178b70 100644 --- a/src/db_controller.rs +++ b/src/db_controller.rs @@ -4,7 +4,7 @@ use sea_orm::{ ActiveModelTrait, ColumnTrait, Database, DatabaseConnection, DatabaseTransaction, DbErr, EntityTrait, PaginatorTrait, QueryFilter, Set, TransactionTrait, }; -use wd_log::{log_error_ln, log_info_ln, log_warn_ln}; +use wd_log::{log_error_ln, log_info_ln, log_panic, log_warn_ln}; const PAGE_SIZE: usize = 25; @@ -185,6 +185,9 @@ impl Controller { } pub fn err_handler(&self, error: DbErr) { - log_error_ln!("{}", error); + match error { + DbErr::Conn(err) => log_panic!("{}", err), + error => log_error_ln!("{}", error), + } } } diff --git a/src/main.rs b/src/main.rs index c3fb932..2fee046 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ async fn main() { }; if let Err(err) = bot.init().await { - log_panic!("{}", err); + bot.controller.err_handler(err); } bot.run().await;