From f098904ab9ea332e89f16e85ebbe004255a661b0 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sat, 19 Sep 2026 11:39:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E9=80=82=E9=85=8D=20Gitea=20act=5Fr?= =?UTF-8?q?unner=EF=BC=8C=E9=87=87=E7=94=A8=E5=8E=9F=E7=94=9F=20docker=20?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=B8=8E=E6=9E=84=E5=BB=BA=E6=8E=A8=E9=80=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3=E9=95=9C=E5=83=8F=E6=BA=90=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build.yaml | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index b9d6f8b..0feeee3 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -15,31 +15,21 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Log in to Gitea Container Registry - uses: docker/login-action@v3 - with: - registry: git.openlocalpdf.com:222 - username: ${{ gitea.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login git.openlocalpdf.com -u "${{ gitea.actor }}" --password-stdin - - name: Extract metadata for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: git.openlocalpdf.com:222/${{ gitea.repository }} - tags: | - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} - type=ref,event=tag - type=sha,format=short + - name: Build and Push Docker image + run: | + IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}" + echo "Building image: ${IMAGE_NAME}:latest" + docker build -t "${IMAGE_NAME}:latest" -f Dockerfile . + docker push "${IMAGE_NAME}:latest" - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + # 如果是 tag 触发,则同步打 tag 推送 + if [ "${{ github.ref_type }}" = "tag" ]; then + TAG_NAME="${{ github.ref_name }}" + echo "Tag detected: ${TAG_NAME}" + docker tag "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${TAG_NAME}" + docker push "${IMAGE_NAME}:${TAG_NAME}" + fi