name: Update builder-jammy-full image

on:
  schedule:
    - cron: '0 * * * *'

jobs:
  build-and-push-image:
    permissions:
      contents: read
      packages: write
    runs-on: "ubuntu-latest"
    steps:
      - uses: actions/checkout@v4
      - uses: knative/actions/setup-go@main
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Build and Push
        env:
          GITHUB_TOKEN: ${{ github.token }}
        run: |
          docker run -d -p 5000:5000 --name registry registry:2.7
          echo '{"insecure-registries" : "localhost:5000" }'  | \
            sudo tee /etc/docker/daemon.json
          mkdir -p "$HOME/.config/containers/"
          echo -e '\n[[registry]]\nlocation = "localhost:5000"\ninsecure = true\n' >> \
            "$HOME/.config/containers/registries.conf"
          skopeo login ghcr.io -u gh-action -p "$GITHUB_TOKEN"
          docker login ghcr.io -u gh-action -p "$GITHUB_TOKEN"
          make __update-builder

