build.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. name: Build
  2. on:
  3. workflow_call:
  4. env:
  5. DOCKER_META_IMAGES: |
  6. darthsim/imgproxy
  7. ghcr.io/imgproxy/imgproxy
  8. DOCKER_META_TAGS: |
  9. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
  10. type=ref,event=branch,enable=${{ startsWith(github.ref, 'refs/heads/test/') }}
  11. type=ref,event=tag
  12. type=semver,pattern=v{{major}}.{{minor}}
  13. type=semver,pattern=v{{major}}
  14. jobs:
  15. build:
  16. if: github.repository_owner == 'imgproxy'
  17. strategy:
  18. matrix:
  19. build:
  20. - arch: amd64
  21. dockerPlatform: linux/amd64
  22. image: linux-5.0
  23. - arch: arm64
  24. dockerPlatform: linux/arm64/v8
  25. image: arm-3.0
  26. runs-on:
  27. - codebuild-imgproxy-${{ github.run_id }}-${{ github.run_attempt }}
  28. - image:${{ matrix.build.image }}
  29. permissions:
  30. contents: read
  31. packages: write
  32. steps:
  33. - name: Checkout
  34. uses: actions/checkout@v4
  35. - name: Docker meta
  36. id: meta
  37. uses: docker/metadata-action@v5
  38. with:
  39. images: ${{ env.DOCKER_META_IMAGES }}
  40. tags: ${{ env.DOCKER_META_TAGS }}
  41. flavor: |
  42. latest=false
  43. suffix=-${{ matrix.build.arch }}
  44. - name: Login to Docker Hub
  45. uses: docker/login-action@v3
  46. with:
  47. username: ${{ vars.DOCKERHUB_USERNAME }}
  48. password: ${{ secrets.DOCKERHUB_TOKEN }}
  49. - name: Login to GitHub Container Registry
  50. uses: docker/login-action@v3
  51. with:
  52. registry: ghcr.io
  53. username: ${{ github.actor }}
  54. password: ${{ secrets.GITHUB_TOKEN }}
  55. - name: Build and push
  56. uses: docker/build-push-action@v6
  57. with:
  58. context: .
  59. file: ./docker/Dockerfile
  60. tags: ${{ steps.meta.outputs.tags }}
  61. labels: ${{ steps.meta.outputs.labels }}
  62. platforms: ${{ matrix.build.dockerPlatform }}
  63. provenance: false
  64. push: true
  65. push_manifests:
  66. needs: build
  67. runs-on: ubuntu-latest
  68. permissions:
  69. contents: read
  70. packages: write
  71. steps:
  72. - name: Docker meta
  73. id: meta
  74. uses: docker/metadata-action@v5
  75. with:
  76. images: ${{ env.DOCKER_META_IMAGES }}
  77. tags: ${{ env.DOCKER_META_TAGS }}
  78. flavor: |
  79. latest=false
  80. env:
  81. DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
  82. - name: Login to Docker Hub
  83. uses: docker/login-action@v3
  84. with:
  85. username: ${{ vars.DOCKERHUB_USERNAME }}
  86. password: ${{ secrets.DOCKERHUB_TOKEN }}
  87. - name: Login to GitHub Container Registry
  88. uses: docker/login-action@v3
  89. with:
  90. registry: ghcr.io
  91. username: ${{ github.actor }}
  92. password: ${{ secrets.GITHUB_TOKEN }}
  93. - name: Push manifests
  94. run: |
  95. ANNOTATIONS=""
  96. for annotation in "${{ join(fromJSON(steps.meta.outputs.json).annotations, '" "') }}"
  97. do
  98. ANNOTATIONS="$ANNOTATIONS --annotation '$annotation'";
  99. done
  100. for tag in ${{ join(fromJSON(steps.meta.outputs.json).tags, ' ') }}
  101. do
  102. sh -c "docker buildx imagetools create ${ANNOTATIONS} -t $tag ${tag}-amd64 ${tag}-arm64"
  103. done