docker.yml 2.4 KB

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