name: Create containers
on:
  workflow_dispatch:
  schedule:
    - cron:  '0 0 * * *'

permissions:
  contents: read

jobs:
  push_to_registry:
    permissions:
      packages: write # for docker/build-push-action
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        os: [precommit, fedora, debian-x86_64, arch, debian-i386, ubuntu-x86_64, centos]

    steps:
      - name: Check out the repo
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - name: "Generate Dockerfile"
        env:
          OS: ${{ matrix.os }}
        run: ./contrib/ci/generate_docker.py
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
      - name: Login to GitHub Container Registry
        uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Push to GitHub Packages
        uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
        with:
          context: .
          push: true
          tags: ghcr.io/fwupd/fwupd/fwupd-${{matrix.os}}:latest
