docker-release.yaml 5.4 KB

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