name: Linux build

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v4
      - name: Install SSH keys
        if: ${{ github.event_name == 'push' }}
        env:
          SSH_ID: ${{ secrets.SSH_ID }}
        run: ./.scripts/install_ssh_id.sh
      - name: Install packages
        run: |
          SYSROOT_DIR="/" ./.scripts/install-freemint.sh binutils gcc mintbin
          ./.scripts/install-freemint.sh mintlib
      - name: Setup environment
        env:
          PROJECT_VERSION: "5.3"
        run: ./.scripts/setup_env.sh
      - name: build
        run: ./.scripts/build.sh
      - name: deploy
        if: ${{ github.event_name == 'push' }}
        env:
          COMMITER_NAME: ${{ github.event.commits[0].author.name }}
          COMMITER_EMAIL: ${{ github.event.commits[0].author.email }}
        run: ./.scripts/deploy.sh
