name: Build
concurrency:
  group: "master-build"

on:
  workflow_dispatch:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: fast
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - run: mkdir build
    - name: Download meta 🔧
      uses: luet-lab/luet-github-action@v0.3.1
      with:
        FINAL_REPO: quay.io/kairos/packages
        REPOSITORY_TYPE: docker
        downloadAllMeta: true
        downloadFromList: false
        downloadMeta: true
        # renovate: datasource=github-releases depName=mudler/luet
        luetVersion: 0.36.0
    - name: Build packages 🔧
      uses: luet-lab/luet-github-action@v0.3.1
      if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
      with:
        build: true
        fromIndex: true
        onlyMissing: true
        FINAL_REPO: quay.io/kairos/packages
        DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }}
        DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
        DOCKER_ENDPOINT: quay.io
        REPOSITORY_TYPE: docker
        pushFinalImages: true
        pushCache: true
        values: values/amd64.yaml
        # renovate: datasource=github-releases depName=mudler/luet
        luetVersion: 0.36.0
    - name: Create repo 🔧
      uses: luet-lab/luet-github-action@v0.3.1
      id: create_repo
      if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
      with:
        FINAL_REPO: quay.io/kairos/packages
        DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }}
        DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
        DOCKER_ENDPOINT: quay.io
        REPOSITORY_TYPE: docker
        createRepo: true
        pushCache: true
        revisionSHA: true
        # renovate: datasource=github-releases depName=mudler/luet
        luetVersion: 0.36.0
    - name: Summary info
      run: |
        echo "Repo created at quay.io/kairos/packages:${{ steps.create_repo.outputs.LUET_PUSHED_REPO }}-repository.yaml" >> $GITHUB_STEP_SUMMARY
