Files
capcut-mate/.github/workflows/dev.yml

78 lines
2.2 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: Docker Image CI Dev
on:
push:
tags:
- 'v*' # 仅在推送 v 开头的 tag 时触发打包
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 准备代码
uses: actions/checkout@v4
- name: 查看文件和目录结构
run: ls -lha
- name: 准备生产环境文件
run: |
mkdir -p dist/etc
# 复制源代码
cp -rf src dist/
cp -rf config dist/
cp -rf template dist/
# 复制依赖配置文件
cp pyproject.toml dist/
cp *.py dist/
cp uv.lock dist/
echo "${{ github.sha }}" > dist/etc/commit_hash
- name: 查看文件和目录结构
run: ls -lha dist -R
- name: 准备打包Docker镜像的环境
uses: docker/setup-buildx-action@v3
# 登录到Docker Hub
- name: 登录Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 提取标签信息 - 使用与登录相同的Secret变量名
- name: 提取镜像标签
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/capcut-mate # 统一使用DOCKERHUB_USERNAME无下划线
tags: |
type=ref,event=tag
type=sha,format=short
type=raw,value=latest
# 调试步骤:检查生成的标签
- name: 显示生成的镜像标签
run: |
echo "生成的标签: ${{ steps.meta.outputs.tags }}"
# 检查标签是否包含正确的用户名格式
if [[ ! "${{ steps.meta.outputs.tags }}" == *"${{ secrets.DOCKERHUB_USERNAME }}/capcut-mate:"* ]]; then
echo "错误:标签格式不正确,应为 ${secrets.DOCKERHUB_USERNAME}/capcut-mate:标签"
exit 1
fi
# 构建并推送Docker镜像
- name: 构建并推送Docker镜像
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max