PeerTube/.github/workflows/docker.yml

87 lines
2.4 KiB
YAML
Raw Normal View History

2021-11-30 16:00:59 +01:00
name: Docker
permissions: {}
2021-11-30 16:00:59 +01:00
on:
push:
branches:
- 'master'
schedule:
- cron: '0 3 * * *'
2024-07-01 10:53:19 +02:00
workflow_call:
2021-11-30 16:00:59 +01:00
jobs:
generate-matrix:
name: Generate matrix for Docker build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
2024-02-06 07:34:58 +01:00
uses: actions/checkout@v4
2021-11-30 16:00:59 +01:00
with:
ref: master
- name: Set matrix for build
id: set-matrix
run: |
# FIXME: https://github.com/actions/checkout/issues/290
git fetch --force --tags
2024-07-01 10:50:29 +02:00
one="{ \"build-peertube\": true, \"file\": \"./support/docker/production/Dockerfile.bookworm\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube:develop-bookworm\" }"
two="{ \"build-peertube\": true, \"file\": \"./support/docker/production/Dockerfile.bookworm\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube:production-bookworm,chocobozzz/peertube:$(git describe --abbrev=0)-bookworm\" }"
three="{ \"build-peertube\": false, \"file\": \"./support/docker/production/Dockerfile.nginx\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-webserver:latest\" }"
2021-11-30 16:00:59 +01:00
2023-03-27 09:00:16 +02:00
matrix="[$one,$two,$three]"
2022-11-02 08:32:57 +01:00
echo "matrix={\"include\":$matrix}" >> $GITHUB_OUTPUT
2021-11-30 16:00:59 +01:00
docker:
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
fail-fast: false
2022-01-03 14:42:53 +01:00
name: ${{ matrix.tags }}
2021-11-30 16:00:59 +01:00
steps:
2024-07-01 10:50:29 +02:00
-
name: Checkout develop
uses: actions/checkout@v4
with:
ref: ${{ matrix.ref }}
- uses: './.github/actions/reusable-prepare-peertube-build'
if: ${{ matrix.build-peertube }}
with:
node-version: '18.x'
- name: Build
if: ${{ matrix.build-peertube }}
run: npm run build
2021-11-30 16:00:59 +01:00
-
name: Set up QEMU
2024-07-01 10:50:29 +02:00
uses: docker/setup-qemu-action@v3
2021-11-30 16:00:59 +01:00
-
name: Set up Docker Buildx
2024-07-01 10:50:29 +02:00
uses: docker/setup-buildx-action@v3
2021-11-30 16:00:59 +01:00
-
name: Login to DockerHub
2024-07-01 10:50:29 +02:00
uses: docker/login-action@v3
2021-11-30 16:00:59 +01:00
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Docker build
2024-07-01 10:50:29 +02:00
uses: docker/build-push-action@v6
2021-11-30 16:00:59 +01:00
with:
context: '.'
2023-03-27 09:00:16 +02:00
platforms: linux/amd64,linux/arm64
2021-11-30 16:00:59 +01:00
push: true
file: ${{ matrix.file }}
tags: ${{ matrix.tags }}
2024-07-01 10:50:29 +02:00
build-args: ALREADY_BUILT=1