name: Update APIs

on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

permissions:
  contents: write

jobs:
  update:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        branches: ["master", "stable30", "stable29", "stable28", "stable27", "stable26", "stable25", "stable24", "stable23"]

    name: Update ${{ matrix.branches }}

    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ matrix.branches }}
          submodules: true
      
      - name: Get latest build script
        run: |
          wget https://raw.githubusercontent.com/nextcloud-deps/ocp/master/build.sh -O build.sh

      - name: Update and push OCP
        run: ./build.sh
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
