Files
jiang13-forum/.github/workflows/docker.yml
freefire c07d1fd2bd
Some checks failed
Docker / docker (push) Has been cancelled
feat: 新增 Docker 容器化部署,支持 Docker Hub 镜像发布
多阶段 Dockerfile、Compose、/health 探活与 JIANG13_* 环境变量;
entrypoint 自动修正 /data 卷权限,适配 1Panel 等平台;更新 README 部署文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-23 18:30:53 +08:00

59 lines
1.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 构建并推送 Docker 镜像到 Docker Hub
# 前置条件:在 GitHub 仓库 Secrets 中配置
# DOCKERHUB_USERNAME — Docker Hub 用户名
# DOCKERHUB_TOKEN — Docker Hub Access Token需 Read & Write 权限)
name: Docker
on:
push:
branches:
- main
tags:
- 'v*'
env:
IMAGE_NAME: hangzhang714128/jiang13-forum
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 计算镜像标签与版本
id: meta
run: |
IMAGE="${{ env.IMAGE_NAME }}"
TAGS="${IMAGE}:latest"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
RAW="${GITHUB_REF#refs/tags/}"
VER="${RAW#v}"
TAGS="${TAGS},${IMAGE}:${VER},${IMAGE}:${RAW}"
echo "version=${VER}" >> "$GITHUB_OUTPUT"
else
SHA="${GITHUB_SHA::7}"
TAGS="${TAGS},${IMAGE}:sha-${SHA}"
echo "version=dev" >> "$GITHUB_OUTPUT"
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
- name: 登录 Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 构建并推送镜像
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
build-args: |
VERSION=${{ steps.meta.outputs.version }}
IMAGE_PREFIX=
tags: ${{ steps.meta.outputs.tags }}