aboutsummaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/docker.yml
blob: f6af8484a69f350efa6b33efb585c1ea630fb3fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Docker

on:
  push:
    branches:
      - 'master'
  schedule:
    - cron: '0 3 * * *'

jobs:
  generate-matrix:
    name: Generate matrix for Docker build
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: master
      - name: Set matrix for build
        id: set-matrix
        run: |
          # FIXME: https://github.com/actions/checkout/issues/290
          git fetch --force --tags

          one="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube:develop-bullseye\", \"platforms\": \"linux/amd64\" }"
          two="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube:develop-bullseye\", \"platforms\": \"linux/arm64\" }"
          three="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube:production-bullseye,chocobozzz/peertube:$(git describe --abbrev=0)-bullseye\", \"platforms\": \"linux/amd64\" }"
          four="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube:production-bullseye,chocobozzz/peertube:$(git describe --abbrev=0)-bullseye\", \"platforms\": \"linux/arm64\" }"
          five="{ \"file\": \"./support/docker/production/Dockerfile.nginx\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-webserver:latest\", \"platforms\": \"linux/amd64,linux/arm64\" }"

          matrix="[$one,$two,$three,$four,$five]"
          echo "matrix={\"include\":$matrix}" >> $GITHUB_OUTPUT

  docker:
    runs-on: ubuntu-latest

    needs: generate-matrix

    strategy:
      matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
      fail-fast: false

    name: ${{ matrix.tags }}

    steps:
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      -
        name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      -
        name: Checkout develop
        uses: actions/checkout@v3
        with:
          ref: ${{ matrix.ref }}
      -
        name: Docker build
        uses: docker/build-push-action@v3
        with:
          context: '.'
          platforms: ${{ matrix.platforms }}
          push: true
          file: ${{ matrix.file }}
          tags: ${{ matrix.tags }}