v1.9.5: 优化并行模式、图片序列号,提高编辑器稳定性 #44
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: | |
| tags: | |
| - 'v*' | |
| 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 | |
| timeout-minutes: 120 | |
| strategy: | |
| matrix: | |
| build_type: [cpu, gpu] | |
| steps: | |
| - name: Free Disk Space | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo docker image prune --all --force | |
| echo "Disk space after cleanup:" | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - 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 }} | |
| 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 }} |