build.yml 3.2 KB

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