Support docker

This commit is contained in:
LuckyHunter
2022-10-21 10:11:09 +08:00
parent f23bb2d9d9
commit e2fb056be3
6 changed files with 134 additions and 4 deletions

73
.github/workflows/docker-builder.yml vendored Normal file
View File

@@ -0,0 +1,73 @@
name: Docker image release
on:
push:
branches:
- "main"
paths-ignore:
- "**.md"
workflow_dispatch:
jobs:
buildx-dockerhub:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lower case
id: string
uses: ASzc/change-string-case-action@v2
with:
string: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
push: true
tags: ${{ steps.string.outputs.lowercase }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Sync README.md
uses: ms-jpq/sync-dockerhub-readme@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
readme: "./README.md"
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

21
.github/workflows/run-by-docker.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: "SMZDM Check-in Bot by Docker"
on:
workflow_dispatch:
# Uncomment below to schedule your job
# schedule:
# - cron: "0 18 * * *"
jobs:
container-test-job:
runs-on: ubuntu-latest
container:
image: enwaiax/smzdm_bot
env:
SMZDM_COOKIE: ${{ secrets.SMZDM_COOKIE }}
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }}
SC_KEY: ${{ secrets.SC_KEY }}
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_USER_ID: ${{ secrets.TG_USER_ID }}

View File

@@ -32,4 +32,7 @@ jobs:
env:
SMZDM_COOKIE: ${{ secrets.SMZDM_COOKIE }}
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }}
SC_KEY: ${{ secrets.SC_KEY }}
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_USER_ID: ${{ secrets.TG_USER_ID }}
run: python main.py