Docker: 修复 COPY 命令语法错误 #14
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| push_to_registry: | |
| description: 'Push to Docker registry' | |
| required: true | |
| default: 'true' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| env: | |
| # Docker Hub 用户名(硬编码) | |
| DOCKERHUB_USERNAME: hgmzhn | |
| # 镜像名称 | |
| IMAGE_NAME: manga-translator | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| build_type: [cpu, gpu] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download pydensecrf wheel | |
| run: | | |
| mkdir -p packaging | |
| wget -q https://github.com/hgmzhn/manga-translator-ui/releases/download/v1.9.2/pydensecrf-1.0-cp312-cp312-linux_x86_64.whl -O packaging/pydensecrf-1.0-cp312-cp312-linux_x86_64.whl || echo "Wheel not found, will build from source" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: hgmzhn | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch,suffix=-${{ matrix.build_type }} | |
| type=ref,event=pr,suffix=-${{ matrix.build_type }} | |
| type=semver,pattern={{version}},suffix=-${{ matrix.build_type }} | |
| type=semver,pattern={{major}}.{{minor}},suffix=-${{ matrix.build_type }} | |
| type=raw,value=latest-${{ matrix.build_type }},enable={{is_default_branch}} | |
| flavor: | | |
| latest=false | |
| - name: Build and push Docker image | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./packaging/Dockerfile | |
| push: ${{ github.event_name != 'pull_request' && (github.event.inputs.push_to_registry != 'false') }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| BUILD_TYPE=${{ matrix.build_type }} | |
| CUDA_VERSION=12.1.0 | |
| PYTHON_VERSION=3.12 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/amd64 | |
| - name: Image digest | |
| run: echo ${{ steps.build.outputs.digest }} |