build.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. name: Build
  2. on:
  3. workflow_call:
  4. env:
  5. DOCKER_META_IMAGES: |
  6. darthsim/imgproxy
  7. DOCKER_META_TAGS: |
  8. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
  9. type=ref,event=branch,enable=${{ startsWith(github.ref, 'refs/heads/test/') }}
  10. type=semver,pattern=v{{version}}
  11. type=semver,pattern=v{{major}}.{{minor}}
  12. type=semver,pattern=v{{major}}
  13. jobs:
  14. build:
  15. strategy:
  16. matrix:
  17. build:
  18. - arch: amd64
  19. dockerPlatform: linux/amd64
  20. image: linux-5.0
  21. - arch: arm64
  22. dockerPlatform: linux/arm64/v8
  23. image: arm-3.0
  24. runs-on:
  25. - codebuild-imgproxy-${{ github.run_id }}-${{ github.run_attempt }}
  26. - image:${{ matrix.build.image }}
  27. steps:
  28. - name: Checkout
  29. uses: actions/checkout@v4
  30. - name: Docker meta
  31. id: meta
  32. uses: docker/metadata-action@v5
  33. with:
  34. images: ${{ env.DOCKER_META_IMAGES }}
  35. tags: ${{ env.DOCKER_META_TAGS }}
  36. flavor: |
  37. latest=false
  38. suffix=-${{ matrix.build.arch }}
  39. - name: Login to Docker Hub
  40. uses: docker/login-action@v3
  41. with:
  42. username: ${{ vars.DOCKERHUB_USERNAME }}
  43. password: ${{ secrets.DOCKERHUB_TOKEN }}
  44. - name: Set up Docker Buildx
  45. uses: docker/setup-buildx-action@v3
  46. - name: Build and push
  47. uses: docker/build-push-action@v6
  48. with:
  49. context: .
  50. file: ./docker/Dockerfile
  51. tags: ${{ steps.meta.outputs.tags }}
  52. labels: ${{ steps.meta.outputs.labels }}
  53. platforms: ${{ matrix.build.dockerPlatform }}
  54. push: true
  55. push_manifests:
  56. needs: build
  57. runs-on: ubuntu-latest
  58. steps:
  59. - name: Docker meta
  60. id: meta
  61. uses: docker/metadata-action@v5
  62. with:
  63. images: ${{ env.DOCKER_META_IMAGES }}
  64. tags: ${{ env.DOCKER_META_TAGS }}
  65. flavor: |
  66. latest=false
  67. - name: Login to Docker Hub
  68. uses: docker/login-action@v3
  69. with:
  70. username: ${{ vars.DOCKERHUB_USERNAME }}
  71. password: ${{ secrets.DOCKERHUB_TOKEN }}
  72. - name: Push manifests
  73. run: |
  74. for tag in ${{ join(fromJSON(steps.meta.outputs.json).tags, ' ') }}
  75. do
  76. docker buildx imagetools create -t $tag ${tag}-amd64 ${tag}-arm64
  77. done