This commit is contained in:
senset 2022-06-29 10:13:09 +08:00
parent af9c05d805
commit 0dcf74819d
3 changed files with 14 additions and 59 deletions

View File

@ -1,66 +1,18 @@
name: Docker name: Docker Image CI
# 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.
on: on:
push: push:
branches: [master] branches: [ "master" ]
# Publish semver tags as releases.
tags: ["v*.*.*"]
pull_request: pull_request:
branches: [master] branches: [ "master" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps: steps:
- name: Checkout repository - uses: actions/checkout@v3
uses: actions/checkout@v2 - name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- 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 }}

View File

@ -4,7 +4,7 @@ use sea_orm::{
ActiveModelTrait, ColumnTrait, Database, DatabaseConnection, DatabaseTransaction, DbErr, ActiveModelTrait, ColumnTrait, Database, DatabaseConnection, DatabaseTransaction, DbErr,
EntityTrait, PaginatorTrait, QueryFilter, Set, TransactionTrait, 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; const PAGE_SIZE: usize = 25;
@ -185,6 +185,9 @@ impl Controller {
} }
pub fn err_handler(&self, error: DbErr) { pub fn err_handler(&self, error: DbErr) {
log_error_ln!("{}", error); match error {
DbErr::Conn(err) => log_panic!("{}", err),
error => log_error_ln!("{}", error),
}
} }
} }

View File

@ -29,7 +29,7 @@ async fn main() {
}; };
if let Err(err) = bot.init().await { if let Err(err) = bot.init().await {
log_panic!("{}", err); bot.controller.err_handler(err);
} }
bot.run().await; bot.run().await;