name: build-merge-request

on:
  pull_request:
    types: [ "opened", "reopened", "synchronize" ]
  push:
    branches: [ "master" ]

env:
  REGISTRY_PULL_HOST: ${{ secrets.REGISTRY_PULL_HOST }}

jobs:
  build:
    env:
      SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
    # Skip the job if the CI was triggered by a pull request that was merged,
    # because the CI was already running for the pull request.
    # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges
    if: github.event.pull_request.merged == false
    runs-on:
    - podman
    steps:
    - uses: dedalus-cis4u/with-standard-setup@v2.0.1
    - name: Run build
      run: |
        make container-run/build/build-settings.rpm \
          BUILD_IMAGE_REGISTRY_HOST=${REGISTRY_PULL_HOST}