build.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. provenance: false
  55. push: true
  56. push_manifests:
  57. needs: build
  58. runs-on: ubuntu-latest
  59. steps:
  60. - name: Docker meta
  61. id: meta
  62. uses: docker/metadata-action@v5
  63. with:
  64. images: ${{ env.DOCKER_META_IMAGES }}
  65. tags: ${{ env.DOCKER_META_TAGS }}
  66. flavor: |
  67. latest=false
  68. - name: Login to Docker Hub
  69. uses: docker/login-action@v3
  70. with:
  71. username: ${{ vars.DOCKERHUB_USERNAME }}
  72. password: ${{ secrets.DOCKERHUB_TOKEN }}
  73. - name: Push manifests
  74. run: |
  75. for tag in ${{ join(fromJSON(steps.meta.outputs.json).tags, ' ') }}
  76. do
  77. docker buildx imagetools create -t $tag ${tag}-amd64 ${tag}-arm64
  78. done