name: validate-install-from-source

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:
  docker:
    name: ${{matrix.vector.image}}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        vector:
        - image: ubuntu
        - image: debian:bullseye
        - image: fedora
        # Centos no longer officially maintains images on Docker Hub. However,
        # tgagor is a contributor who pushes updated images weekly, which should
        # be sufficient for our validation needs.
        - image: tgagor/centos
        - image: redhat/ubi8
        - image: alpine
        - image: alpine:3.14.10
        - image: opensuse/leap
        - image: opensuse/tumbleweed
        - image: registry.suse.com/suse/sle15:15.4.27.11.31
        - image: archlinux
        - image: mcr.microsoft.com/cbl-mariner/base/core:2.0
    container: ${{matrix.vector.image}}
    steps:
      - run: |
          if [[ ${{matrix.vector.image}} == *"suse"* ]]; then
            zypper -n install tar gzip
          elif [[ ${{matrix.vector.image}} == *"centos"* ]]; then
            dnf install which -y
          elif [[ ${{matrix.vector.image}} == *"mariner"* ]]; then
            GNUPGHOME=/root/.gnupg tdnf update -y &&
            GNUPGHOME=/root/.gnupg tdnf install tar -y # needed for `actions/checkout`
          fi

      - uses: actions/checkout@v4

      - run: |
          sh "${GITHUB_WORKSPACE}/src/linux/Packaging.Linux/install-from-source.sh" -y
          git-credential-manager --help || exit 1
