mirror of
https://git.fightbot.fun/hxuanyu/BingPaper.git
synced 2026-02-15 07:19:33 +08:00
新增 GitHub Actions 配置以支持 Docker 镜像自动构建与推送,更新 README 添加使用说明
This commit is contained in:
46
.github/workflows/docker-publish.yml
vendored
Normal file
46
.github/workflows/docker-publish.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: Docker Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
# environment: prod # 如果用户没有设置 GitHub Environment,这一行可能会报错,但模板里有,我先保留
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: hxuanyu521/bingpaper
|
||||
tags: |
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
11
README.md
11
README.md
@@ -98,6 +98,17 @@ go run .
|
||||
3. 脚本会自动推送标签,触发 GitHub Actions 进行构建并发布 Release。
|
||||
|
||||
### Docker 运行
|
||||
|
||||
#### 使用 Docker Hub 镜像 (推荐)
|
||||
```bash
|
||||
docker run -d \
|
||||
--name bingpaper \
|
||||
-p 8080:8080 \
|
||||
-v $(pwd)/data:/app/data \
|
||||
hxuanyu521/bingpaper:latest
|
||||
```
|
||||
|
||||
#### 本地构建镜像
|
||||
```bash
|
||||
docker build -t bing-paper .
|
||||
docker run -d -p 8080:8080 -v $(pwd)/data:/app/data bing-paper
|
||||
|
||||
Reference in New Issue
Block a user