on:
  push:
    paths:
      - contrib/selinux/*
      - .github/workflows/selinux.yml
  pull_request:
    paths:
      - contrib/selinux/*
      - .github/workflows/selinux.yml

jobs:
  build-c7:
    runs-on: ubuntu-latest
    container: centos:7
    steps:
      - name: Prepare
        run: |
          yum install -y selinux-policy-devel
      - uses: actions/checkout@v2
      - name: Build
        run: |
          make -C contrib/selinux
      - name: Archive policy
        uses: actions/upload-artifact@v3
        with:
          name: selinux-el7
          path: contrib/selinux/laurel.pp

  build-c8:
    runs-on: ubuntu-latest
    container: rockylinux:8
    steps:
      - name: Prepare
        run: |
          yum install -y selinux-policy-devel findutils
      - uses: actions/checkout@v2
      - name: Build
        run: |
          make -C contrib/selinux
      - name: Archive policy
        uses: actions/upload-artifact@v3
        with:
          name: selinux-el8
          path: contrib/selinux/laurel.pp

  build-al2:
    runs-on: ubuntu-latest
    container: amazonlinux:2
    steps:
      - name: Prepare
        run: |
          yum install -y selinux-policy-devel findutils tar
      - uses: actions/checkout@v2
      - name: Build
        run: |
          make -C contrib/selinux
      - name: Archive policy
        uses: actions/upload-artifact@v3
        with:
          name: selinux-al2
          path: contrib/selinux/laurel.pp
