docker-release.yaml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. name: docker-release
  2. # See
  3. # https://github.com/docker/docs/issues/18835
  4. # https://docs.docker.com/reference/cli/docker/buildx/imagetools/create/
  5. on:
  6. push:
  7. branches:
  8. - stable
  9. - develop
  10. tags:
  11. - '*'
  12. jobs:
  13. docker-build-image:
  14. strategy:
  15. matrix:
  16. runs-on:
  17. - runner: ubuntu-22.04
  18. platform: 'amd64'
  19. - runner: ['self-hosted', 'arm64']
  20. platform: 'arm64'
  21. runs-on: ${{ matrix.runs-on.runner }}
  22. steps:
  23. - name: Checkout Code
  24. uses: actions/checkout@v4
  25. with:
  26. fetch-depth: 0
  27. - name: Set up Docker Buildx
  28. uses: docker/setup-buildx-action@v3
  29. - name: Login to docker.io container registry
  30. uses: docker/login-action@v3
  31. with:
  32. username: ${{ secrets.DOCKER_USERNAME }}
  33. password: ${{ secrets.DOCKER_PASSWORD }}
  34. - name: Login to GitHub Container Registry
  35. uses: docker/login-action@v3
  36. with:
  37. registry: ghcr.io
  38. username: ${{ github.repository_owner }}
  39. password: ${{ secrets.GITHUB_TOKEN }}
  40. - name: Login to Quay.io
  41. uses: docker/login-action@v3
  42. with:
  43. registry: quay.io
  44. username: ${{ secrets.QUAY_USERNAME }}
  45. password: ${{ secrets.QUAY_ROBOT_TOKEN }}
  46. - name: Get tags for platform specific image
  47. id: meta
  48. uses: docker/metadata-action@v5
  49. with:
  50. images: |
  51. ghcr.io/${{ github.repository_owner }}/zammad
  52. index.docker.io/${{ github.repository_owner }}/zammad
  53. index.docker.io/${{ github.repository_owner }}/zammad-docker-compose
  54. quay.io/${{ github.repository_owner }}/zammad
  55. tags: |
  56. type=sha,suffix=-${{ matrix.runs-on.platform }}
  57. env:
  58. DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor
  59. - name: Build and push
  60. id: docker_build
  61. uses: docker/build-push-action@v6
  62. with:
  63. context: .
  64. labels: ${{ steps.meta.outputs.labels }}
  65. pull: true
  66. push: true
  67. tags: ${{ steps.meta.outputs.tags }}
  68. annotations: ${{ steps.meta.outputs.annotations }}
  69. docker-create-multiarch-manifest:
  70. runs-on: ubuntu-24.04
  71. needs:
  72. - docker-build-image
  73. strategy:
  74. matrix:
  75. target:
  76. - image: ghcr.io/${{ github.repository_owner }}/zammad
  77. - image: index.docker.io/${{ github.repository_owner }}/zammad
  78. - image: quay.io/${{ github.repository_owner }}/zammad
  79. - image: index.docker.io/${{ github.repository_owner }}/zammad-docker-compose
  80. steps:
  81. - name: Checkout Code
  82. uses: actions/checkout@v4
  83. with:
  84. fetch-depth: 0
  85. - name: Set up Docker Buildx
  86. uses: docker/setup-buildx-action@v3
  87. - name: Login to docker.io container registry
  88. uses: docker/login-action@v3
  89. with:
  90. username: ${{ secrets.DOCKER_USERNAME }}
  91. password: ${{ secrets.DOCKER_PASSWORD }}
  92. - name: Login to GitHub Container Registry
  93. uses: docker/login-action@v3
  94. with:
  95. registry: ghcr.io
  96. username: ${{ github.repository_owner }}
  97. password: ${{ secrets.GITHUB_TOKEN }}
  98. - name: Login to Quay.io
  99. uses: docker/login-action@v3
  100. with:
  101. registry: quay.io
  102. username: ${{ secrets.QUAY_USERNAME }}
  103. password: ${{ secrets.QUAY_ROBOT_TOKEN }}
  104. - name: Get tag for amd64 image
  105. id: meta_arch_amd64
  106. uses: docker/metadata-action@v5
  107. with:
  108. images: ${{ matrix.target.image }}
  109. tags: |
  110. type=sha,suffix=-amd64
  111. - name: Get tag for arm64 image
  112. id: meta_arch_arm64
  113. uses: docker/metadata-action@v5
  114. with:
  115. images: ${{ matrix.target.image }}
  116. tags: |
  117. type=sha,suffix=-arm64
  118. - name: Get incrementing Zammad version from the most recent tag
  119. run: echo ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')" >> $GITHUB_ENV
  120. - name: Get Zammad major.minor version from the most recent tag
  121. run: echo ZAMMAD_VERSION_MAJOR_MINOR="$(git describe --tags | cut -f1-2 -d.)" >> $GITHUB_ENV
  122. - name: Get Zammad major version from the most recent tag
  123. run: echo ZAMMAD_VERSION_MAJOR="$(git describe --tags | cut -f1 -d.)" >> $GITHUB_ENV
  124. - name: Get tags for final multiarch reference
  125. id: meta
  126. uses: docker/metadata-action@v5
  127. with:
  128. images: ${{ matrix.target.image }}
  129. # Don't automatically generate a 'latest' tag for the default branch.
  130. # https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input
  131. flavor: |
  132. latest=false
  133. tags: |
  134. type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  135. type=raw,value=${{ env.ZAMMAD_VERSION }},enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  136. type=raw,value=${{ env.ZAMMAD_VERSION_MAJOR_MINOR }},enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  137. type=raw,value=${{ env.ZAMMAD_VERSION_MAJOR }},enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  138. type=ref,event=branch
  139. type=ref,event=tag
  140. type=sha
  141. env:
  142. DOCKER_METADATA_ANNOTATIONS_LEVELS: index
  143. - name: Create manifest list and push
  144. # Build and run a complex command line with eval to avoid wrong word splitting on spaces in the annotations.
  145. run: |
  146. eval "docker buildx imagetools create \
  147. $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  148. $(jq -cr '.annotations | map("--annotation \"" + . + "\"") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  149. ${{ steps.meta_arch_amd64.outputs.tags }} \
  150. ${{ steps.meta_arch_arm64.outputs.tags }}"
  151. - name: Inspect image
  152. run: |
  153. docker buildx imagetools inspect ${{ matrix.target.image }}:${{ steps.meta.outputs.version }}