diff --git a/.gitea/workflows/docker_build.yml b/.gitea/workflows/docker_build.yml index 6bd8966..1b6e8d2 100644 --- a/.gitea/workflows/docker_build.yml +++ b/.gitea/workflows/docker_build.yml @@ -1,4 +1,4 @@ -name: Build and Run Docker Image +name: Build and Push Docker Image on: push: @@ -12,15 +12,25 @@ on: branches: ["main"] env: + REGISTRY: http://113.44.68.213:3000 IMAGE_NAME: ${{ gitea.repository }} jobs: - build-and-run: + build-and-push: runs-on: ubuntu-latest permissions: contents: read + packages: write steps: + - name: 获取 Gitea 配置 + run: | + echo ${{ env.REGISTRY }} + echo ${{ gitea.actor }} + exho ${{ secrets.GHCR_USER }} + echo ${{ secrets.GHCR_TOKEN }} + echo ${{ env.IMGAE_NAME }} + - name: 检出代码 uses: actions/checkout@v4 @@ -35,19 +45,40 @@ jobs: echo "env_suffix=prod" >> $GITHUB_OUTPUT else echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT - fi + fi - - name: 设置 Docker 镜像标签 - id: docker_tags - run: | - echo "tag=${{ env.IMAGE_NAME }}:${{ steps.branch_name.outputs.env_suffix }}" >> $GITHUB_OUTPUT + - name: 登录到 Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + # insecure: true # 允许 HTTP 连接 # Err: 无效 - - name: 构建 Docker 镜像 - run: | - docker build -t ${{ steps.docker_tags.outputs.tag }} . +# - name: 提取 Docker 元数据 +# id: meta +# uses: docker/metadata-action@v5 +# with: +# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} +# tags: | +# # main 分支使用标准标签 +# type=raw,value=latest,enable=${{ steps.branch_name.outputs.branch == 'main' }} +# type=raw,value=${{ steps.branch_name.outputs.env_suffix }} +# type=sha,format=short,prefix=${{ steps.branch_name.outputs.env_suffix }}- +# type=ref,event=tag,prefix=${{ steps.branch_name.outputs.env_suffix }}- - - name: 运行 Docker 容器 - run: | - docker run -d --name catface_${{ steps.branch_name.outputs.env_suffix }} \ - -p 20201:20201 \ - ${{ steps.docker_tags.outputs.tag }} \ No newline at end of file +# - name: 构建并推送 Docker 镜像 +# uses: docker/build-push-action@v5 +# with: +# context: . +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} +# build-args: | +# BUILDKIT_INLINE_CACHE=0 +# # 添加清理缓存的命令 +# outputs: type=docker,cleancache=true + +# - name: Trigger Portainer Webhook +# run: | +# curl -k -X POST ${{ secrets.BACKEND_WEBHOOK_URL }}