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