docker.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # GitHub actions workflow which builds and publishes the docker images.
  2. name: Build docker images
  3. on:
  4. push:
  5. tags: ["v*"]
  6. branches: [ master, main, develop ]
  7. workflow_dispatch:
  8. permissions:
  9. contents: read
  10. jobs:
  11. build:
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Set up QEMU
  15. id: qemu
  16. uses: docker/setup-qemu-action@v1
  17. with:
  18. platforms: arm64
  19. - name: Set up Docker Buildx
  20. id: buildx
  21. uses: docker/setup-buildx-action@v1
  22. - name: Inspect builder
  23. run: docker buildx inspect
  24. - name: Log in to DockerHub
  25. uses: docker/login-action@v1
  26. with:
  27. username: ${{ secrets.DOCKERHUB_USERNAME }}
  28. password: ${{ secrets.DOCKERHUB_TOKEN }}
  29. - name: Calculate docker image tag
  30. id: set-tag
  31. run: |
  32. case "${GITHUB_REF}" in
  33. refs/heads/develop)
  34. tag=develop
  35. ;;
  36. refs/heads/master|refs/heads/main)
  37. tag=latest
  38. ;;
  39. refs/tags/*)
  40. tag=${GITHUB_REF#refs/tags/}
  41. ;;
  42. *)
  43. tag=${GITHUB_SHA}
  44. ;;
  45. esac
  46. echo "::set-output name=tag::$tag"
  47. # for release builds, we want to get the amd64 image out asap, so first
  48. # we do an amd64-only build, before following up with a multiarch build.
  49. - name: Build and push amd64
  50. uses: docker/build-push-action@v2
  51. if: "${{ startsWith(github.ref, 'refs/tags/v') }}"
  52. with:
  53. push: true
  54. labels: "gitsha1=${{ github.sha }}"
  55. tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
  56. file: "docker/Dockerfile"
  57. platforms: linux/amd64
  58. - name: Build and push all platforms
  59. uses: docker/build-push-action@v2
  60. with:
  61. push: true
  62. labels: "gitsha1=${{ github.sha }}"
  63. tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
  64. file: "docker/Dockerfile"
  65. platforms: linux/amd64,linux/arm64