Files
my-docs/.github/workflows/buidl_and_push_ghcr.yml
gitea_admin f7e8a7b3b3
Some checks failed
Build and Push Docs / build-push (push) Failing after 2m42s
更新 .github/workflows/buidl_and_push_ghcr.yml
2025-12-18 13:20:31 +00:00

56 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.

name: Build and Push Docs
run-name: Build Docs - ${{ gitea.actor }}
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
jobs:
build-push:
runs-on: ubuntu-latest
steps:
# 1. 检出代码
# 注意:必须包含 nginx/nginx.conf 和 Dockerfile
- name: Checkout
uses: actions/checkout@v3
# 2. 登录镜像仓库
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# 3. 启用 Buildx
# 这是必须的,因为 docker/build-push-action 依赖它
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# 4. 生成 Metadata (自动生成 latest, v1.0.0 等标签)
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_REGISTRY }}/your-image-name
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha,format=short
# 5. 构建并推送
- name: Build and Push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# 开启缓存,加速下一次构建(会缓存各层 Layer
cache-from: type=gha
cache-to: type=gha,mode=max