# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

# Workflow name
name: Run Test

# Run on event push
on: push

jobs:

  #
  # Job build-1-16
  # Build on AlmaLinux 8.5 using golang version 1.16
  #
  AlmaLinux-rpmbuild:
    runs-on: ubuntu-latest
    container: almalinux:8.5
    steps:

    - name: Install dependencies
      run: |
        dnf --assumeyes group install "Development Tools" "RPM Development Tools"
        dnf --assumeyes       install wget

    # See: https://github.com/marketplace/actions/checkout
    # Checkout git repository and submodules
    - name: Checkout
      uses: actions/checkout@v2
      with:
        submodules: recursive
        fetch-depth: 0

    # See: https://github.com/marketplace/actions/setup-go-environment
    - name: Setup Golang
      uses: actions/setup-go@v2
      with:
        go-version: '^1.16.7'

    - name: RPM build MetricCollector
      run: |
        make RPM
        RPM=~/rpmbuild/RPMS/*/*.rpm
        SRPM=~/rpmbuild/SRPMS/*.src.rpm
        echo ::set-output name="SRPM::${SRPM}"
        echo ::set-output name="RPM::${RPM}"
        echo ::set-output name="rpm_content_type::application/octet-stream"

    # See: https://github.com/actions/download-artifact
    - name: Save RPM as artifact
      uses: actions/upload-artifact@v2
      with:
        name: cc-metric-collector RPM AlmaLinux 8.5
        path: ~/rpmbuild/*/*/cc-metric-collector-*.rpm