docker.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: Docker
  2. on:
  3. push:
  4. branches:
  5. - 'master'
  6. schedule:
  7. - cron: '0 3 * * *'
  8. jobs:
  9. generate-matrix:
  10. name: Generate matrix for Docker build
  11. runs-on: ubuntu-latest
  12. outputs:
  13. matrix: ${{ steps.set-matrix.outputs.matrix }}
  14. steps:
  15. - name: Checkout
  16. uses: actions/checkout@v3
  17. with:
  18. ref: master
  19. - name: Set matrix for build
  20. id: set-matrix
  21. run: |
  22. # FIXME: https://github.com/actions/checkout/issues/290
  23. git fetch --force --tags
  24. one="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube:develop-bullseye\" }"
  25. two="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube:production-bullseye,chocobozzz/peertube:$(git describe --abbrev=0)-bullseye\" }"
  26. three="{ \"file\": \"./support/docker/production/Dockerfile.nginx\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-webserver:latest\" }"
  27. matrix="[$one,$two,$three]"
  28. echo "matrix={\"include\":$matrix}" >> $GITHUB_OUTPUT
  29. docker:
  30. runs-on: ubuntu-latest
  31. needs: generate-matrix
  32. strategy:
  33. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  34. fail-fast: false
  35. name: ${{ matrix.tags }}
  36. steps:
  37. -
  38. name: Set up QEMU
  39. uses: docker/setup-qemu-action@v2
  40. -
  41. name: Set up Docker Buildx
  42. uses: docker/setup-buildx-action@v2
  43. -
  44. name: Login to DockerHub
  45. uses: docker/login-action@v2
  46. with:
  47. username: ${{ secrets.DOCKERHUB_USERNAME }}
  48. password: ${{ secrets.DOCKERHUB_TOKEN }}
  49. -
  50. name: Checkout develop
  51. uses: actions/checkout@v3
  52. with:
  53. ref: ${{ matrix.ref }}
  54. -
  55. name: Docker build
  56. uses: docker/build-push-action@v3
  57. with:
  58. context: '.'
  59. platforms: linux/amd64,linux/arm64
  60. push: true
  61. file: ${{ matrix.file }}
  62. tags: ${{ matrix.tags }}