name: release
on:
  schedule:
    - cron: '0 9 * * *'
  workflow_dispatch:

env:
  GIT_CONFIG_COUNT: 1
  GIT_CONFIG_KEY_0: lfs.fetchexclude
  GIT_CONFIG_VALUE_0: openpilot/selfdrive/modeld/models/big_driving_supercombo.onnx

jobs:
  build_masterci:
    name: build master-ci
    runs-on: ubuntu-latest
    if: github.repository == 'commaai/openpilot'
    permissions:
      checks: read
      contents: write
    steps:
    - name: Wait for green check mark
      if: ${{ github.event_name == 'schedule' }}
      uses: lewagon/wait-on-check-action@1d57e2c51a58d812d2765e036a028b6bdb5a6154
      with:
        ref: master
        wait-interval: 30
        running-workflow-name: 'build master-ci'
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        check-regexp: ^((?!.*(build prebuilt|create badges).*).)*$
    - uses: actions/checkout@v4 # checkout version > v4 breaks nightly release script
      with:
        submodules: true
        fetch-depth: 0
    - run: ./tools/op.sh setup
    - name: Push master-ci
      run: BRANCH=__nightly tools/release/build_stripped.sh
