docker.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 ]
  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/master|refs/heads/main)
  34. tag=latest
  35. ;;
  36. refs/tags/*)
  37. tag=${GITHUB_REF#refs/tags/}
  38. ;;
  39. *)
  40. tag=${GITHUB_SHA}
  41. ;;
  42. esac
  43. echo "::set-output name=tag::$tag"
  44. # for release builds, we want to get the amd64 image out asap, so first
  45. # we do an amd64-only build, before following up with a multiarch build.
  46. - name: Build and push amd64
  47. uses: docker/build-push-action@v2
  48. if: "${{ startsWith(github.ref, 'refs/tags/v') }}"
  49. with:
  50. push: true
  51. labels: "gitsha1=${{ github.sha }}"
  52. tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
  53. file: "docker/Dockerfile"
  54. platforms: linux/amd64
  55. - name: Build and push all platforms
  56. uses: docker/build-push-action@v2
  57. with:
  58. push: true
  59. labels: "gitsha1=${{ github.sha }}"
  60. tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
  61. file: "docker/Dockerfile"
  62. platforms: linux/amd64,linux/arm64