name: macOS Latest Build Check

on:
  pull_request:
  push:
    paths:
      - 'Makefile'
  workflow_dispatch:

jobs:
  macos-build-check:
    name: macOS Build Check
    if: github.server_url == 'https://github.com'
    runs-on: macos-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Check system architecture
        run: uname -m

      - name: Install Homebrew
        run: |
          if ! command -v brew &> /dev/null; then
            /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
          fi

      - name: Update Homebrew and install dependencies
        run: |
          brew update
          brew install faad2 taglib chafa fftw opus opusfile libogg libvorbis make curl

      - name: Build code
        run: make
