jobs: # skip-master skip-stable

  # This is ci/actions-templates/freebsd-builds-template.yaml
  # Do not edit this file in .github/workflows
  build-freebsd-master: # job-name skip-stable
  build-freebsd-stable: # job-name skip-master
    runs-on: ubuntu-latest
    if: ${{ (github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'schedule' }} # skip-stable
    if: ${{ github.event_name == 'push' && github.ref_name == 'stable' }} # skip-master
    steps:
    - uses: actions/checkout@v4
      with:
        # v2 defaults to a shallow checkout, but we need at least to the previous tag
        fetch-depth: 0
    - name: Acquire tags for the repo
      run: |
        git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
    - name: Run a full build
      uses: vmactions/freebsd-vm@v1
      with:
        release: 13.2
        usesh: true
        copyback: false
        prepare: |
          pkg install -y git gmake bash sudo \
            `# The following packages are required by 'aws-lc-rs':` \
            cmake-core llvm-devel-lite rust-bindgen-cli
        run: |
          echo "========="
          echo "create non-root user and log into it"
          pw group add -n tester
          pw user add -n tester -g tester -s `which bash`
          pw user mod tester -d `pwd`
          chown -R tester .
          sudo -u tester bash ci/freebsd/script.bash
