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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: "Generate Dockerfile"
        env:
          OS: ${{ matrix.os }}
        run: ./contrib/ci/generate_docker.py
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
      - name: Login to GitHub Container Registry
        uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Push to GitHub Packages
        uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
        with:
          context: .
          push: true
          tags: ghcr.io/fwupd/fwupd/fwupd-${{matrix.os}}:latest
