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