name: Build and release container directly from master

on:
  push:
    branches:
      - "master"
    paths-ignore:
      - "*.md"
      - LICENCE
      - TRANSLATION
      - invidious.service
      - .git*
      - .editorconfig
      - screenshots/*
      - .github/ISSUE_TEMPLATE/*
      - kubernetes/**

jobs:
  release:
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            platform: linux/amd64
            name: "AMD64"
            dockerfile: "docker/Dockerfile"
            tag_suffix: ""
            # GitHub doesn't have a ubuntu-latest-arm runner
          - os: ubuntu-24.04-arm
            platform: linux/arm64/v8
            name: "ARM64"
            dockerfile: "docker/Dockerfile.arm64"
            tag_suffix: "-arm64"

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to registry
        uses: docker/login-action@v3
        with:
          registry: quay.io
          username: ${{ secrets.QUAY_USERNAME }}
          password: ${{ secrets.QUAY_PASSWORD }}

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: quay.io/invidious/invidious
          flavor: |
            suffix=${{ matrix.tag_suffix }}
          tags: |
            type=sha,format=short,prefix={{date 'YYYY.MM.DD'}}-,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
            type=raw,value=master,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
          labels: |
            quay.expires-after=12w

      - name: Build and push Docker ${{ matrix.name }} image for Push Event
        uses: docker/build-push-action@v6
        with:
          context: .
          file:  ${{ matrix.dockerfile }}
          platforms: ${{ matrix.platform }}
          labels: ${{ steps.meta.outputs.labels }}
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          build-args: |
            "release=1"
