jobs: # skip-main skip-stable

  # This is ci/actions-templates/freebsd-builds-template.yaml
  # Do not edit this file in .github/workflows
  build-freebsd-main: # job-name skip-stable
  build-freebsd-stable: # job-name skip-main
    runs-on: ubuntu-latest
    if: ${{ (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'schedule' }} # skip-stable
    if: ${{ github.event_name == 'push' && github.ref_name == 'stable' }} # skip-main
    steps:
    - uses: actions/checkout@v6
      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
