build-docker-image.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. name: Build Image
  2. on:
  3. push:
  4. branches:
  5. - main
  6. tags:
  7. - 'v*'
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest-16c64g
  11. steps:
  12. - uses: actions/checkout@v4
  13. - name: Set up Docker Buildx
  14. uses: docker/setup-buildx-action@v3
  15. - name: Get Version
  16. run: |
  17. if [[ $GITHUB_REF == refs/tags/v* ]]; then
  18. echo "version=$(basename ${GITHUB_REF})" >> $GITHUB_ENV
  19. else
  20. version=dev
  21. echo "version=${version}" >> $GITHUB_ENV
  22. fi
  23. echo "Current version: ${{ env.version }}"
  24. - name: Login to GitHub Container Registry
  25. uses: docker/login-action@v3
  26. with:
  27. registry: ghcr.io
  28. username: ${{ github.repository_owner }}
  29. password: ${{ secrets.GITHUB_TOKEN }}
  30. - name: Login to Docker Hub
  31. uses: docker/login-action@v3
  32. with:
  33. username: ${{ secrets.DOCKER_USER }}
  34. password: ${{ secrets.DOCKER_PAT }}
  35. - name: Build and Push Image
  36. uses: docker/build-push-action@v6
  37. with:
  38. context: .
  39. file: dockerfile
  40. platforms: linux/amd64
  41. push: true
  42. tags: |
  43. ghcr.io/${{ github.repository_owner }}/fish-speech:${{ env.version }}
  44. ghcr.io/${{ github.repository_owner }}/fish-speech:latest
  45. fishaudio/fish-speech:${{ env.version }}
  46. fishaudio/fish-speech:latest
  47. outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
  48. cache-from: type=gha
  49. cache-to: type=gha,mode=max
  50. - name: Build and Push Debug Image
  51. uses: docker/build-push-action@v6
  52. with:
  53. context: .
  54. file: dockerfile.dev
  55. platforms: linux/amd64
  56. push: true
  57. build-args: |
  58. VERSION=${{ env.version }}
  59. BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/fish-speech:${{ env.version }}
  60. tags: |
  61. ghcr.io/${{ github.repository_owner }}/fish-speech:${{ env.version }}-dev
  62. ghcr.io/${{ github.repository_owner }}/fish-speech:latest-dev
  63. fishaudio/fish-speech:${{ env.version }}-dev
  64. fishaudio/fish-speech:latest-dev
  65. outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
  66. cache-from: type=gha
  67. cache-to: type=gha,mode=max
  68. - name: Push README to Dockerhub
  69. uses: christian-korneck/update-container-description-action@v1
  70. env:
  71. DOCKER_USER: ${{ secrets.DOCKER_USER }}
  72. DOCKER_PASS: ${{ secrets.DOCKER_PAT }}
  73. with:
  74. destination_container_repo: fishaudio/fish-speech
  75. provider: dockerhub
  76. short_description: 'Fish Speech official docker container'
  77. readme_file: 'README.md'