docker.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # TODO: consider using https://github.com/docker/metadata-action instead of this
  30. # custom magic
  31. - name: Calculate docker image tag
  32. id: set-tag
  33. run: |
  34. case "${GITHUB_REF}" in
  35. refs/heads/develop)
  36. tag=develop
  37. ;;
  38. refs/heads/master|refs/heads/main)
  39. tag=latest
  40. ;;
  41. refs/tags/*)
  42. tag=${GITHUB_REF#refs/tags/}
  43. ;;
  44. *)
  45. tag=${GITHUB_SHA}
  46. ;;
  47. esac
  48. echo "::set-output name=tag::$tag"
  49. - name: Build and push all platforms
  50. uses: docker/build-push-action@v2
  51. with:
  52. push: true
  53. labels: "gitsha1=${{ github.sha }}"
  54. tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
  55. file: "docker/Dockerfile"
  56. platforms: linux/amd64,linux/arm64