docker-release.yaml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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-24.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. build-args: |
  65. COMMIT_SHA=${{ github.sha }}
  66. labels: ${{ steps.meta.outputs.labels }}
  67. pull: true
  68. push: true
  69. tags: ${{ steps.meta.outputs.tags }}
  70. annotations: ${{ steps.meta.outputs.annotations }}
  71. docker-create-multiarch-manifest:
  72. runs-on: ubuntu-24.04
  73. needs:
  74. - docker-build-image
  75. strategy:
  76. matrix:
  77. target:
  78. - image: ghcr.io/${{ github.repository_owner }}/zammad
  79. - image: index.docker.io/${{ github.repository_owner }}/zammad
  80. - image: quay.io/${{ github.repository_owner }}/zammad
  81. - image: index.docker.io/${{ github.repository_owner }}/zammad-docker-compose
  82. steps:
  83. - name: Checkout Code
  84. uses: actions/checkout@v4
  85. with:
  86. fetch-depth: 0
  87. - name: Set up Docker Buildx
  88. uses: docker/setup-buildx-action@v3
  89. - name: Login to docker.io container registry
  90. uses: docker/login-action@v3
  91. with:
  92. username: ${{ secrets.DOCKER_USERNAME }}
  93. password: ${{ secrets.DOCKER_PASSWORD }}
  94. - name: Login to GitHub Container Registry
  95. uses: docker/login-action@v3
  96. with:
  97. registry: ghcr.io
  98. username: ${{ github.repository_owner }}
  99. password: ${{ secrets.GITHUB_TOKEN }}
  100. - name: Login to Quay.io
  101. uses: docker/login-action@v3
  102. with:
  103. registry: quay.io
  104. username: ${{ secrets.QUAY_USERNAME }}
  105. password: ${{ secrets.QUAY_ROBOT_TOKEN }}
  106. - name: Get tag for amd64 image
  107. id: meta_arch_amd64
  108. uses: docker/metadata-action@v5
  109. with:
  110. images: ${{ matrix.target.image }}
  111. tags: |
  112. type=sha,suffix=-amd64
  113. - name: Get tag for arm64 image
  114. id: meta_arch_arm64
  115. uses: docker/metadata-action@v5
  116. with:
  117. images: ${{ matrix.target.image }}
  118. tags: |
  119. type=sha,suffix=-arm64
  120. - name: Get incrementing Zammad version from the most recent tag
  121. run: echo ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')" >> $GITHUB_ENV
  122. - name: Get Zammad major.minor version from the most recent tag
  123. run: echo ZAMMAD_VERSION_MAJOR_MINOR="$(git describe --tags | cut -f1-2 -d.)" >> $GITHUB_ENV
  124. - name: Get Zammad major version from the most recent tag
  125. run: echo ZAMMAD_VERSION_MAJOR="$(git describe --tags | cut -f1 -d.)" >> $GITHUB_ENV
  126. - name: Get tags for final multiarch reference
  127. id: meta
  128. uses: docker/metadata-action@v5
  129. with:
  130. images: ${{ matrix.target.image }}
  131. # Don't automatically generate a 'latest' tag for the default branch.
  132. # https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input
  133. flavor: |
  134. latest=false
  135. tags: |
  136. type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  137. type=raw,value=${{ env.ZAMMAD_VERSION }},enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  138. type=raw,value=${{ env.ZAMMAD_VERSION_MAJOR_MINOR }},enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  139. type=raw,value=${{ env.ZAMMAD_VERSION_MAJOR }},enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
  140. type=ref,event=branch
  141. type=ref,event=tag
  142. type=sha
  143. env:
  144. DOCKER_METADATA_ANNOTATIONS_LEVELS: index
  145. - name: Create manifest list and push
  146. # Build and run a complex command line with eval to avoid wrong word splitting on spaces in the annotations.
  147. run: |
  148. eval "docker buildx imagetools create \
  149. $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  150. $(jq -cr '.annotations | map("--annotation \"" + . + "\"") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  151. ${{ steps.meta_arch_amd64.outputs.tags }} \
  152. ${{ steps.meta_arch_arm64.outputs.tags }}"
  153. - name: Inspect image
  154. run: |
  155. docker buildx imagetools inspect ${{ matrix.target.image }}:${{ steps.meta.outputs.version }}