name: Check for upstream releases

on:
    schedule:
        - cron: '00 16 * * *'
    workflow_dispatch: {}

permissions:
    contents: write
    pull-requests: write

jobs:
    check:
        name: Check for upstream releases
        runs-on: ubuntu-latest

        steps:
            - name: Checkout
              uses: actions/checkout@v4

            - name: Set up Rust toolchain
              run: |
                  rustup toolchain install nightly --no-self-update --profile default
                  rustup target add wasm32-unknown-unknown

            - name: Set up Rust cache
              uses: swatinem/rust-cache@v2
              with:
                  cache-on-failure: true
                  save-if: ${{ github.ref == 'refs/heads/main' }}

            - name: Install Cargo Binary Install
              uses: cargo-bins/cargo-binstall@main

            - name: Install crates
              run: cargo binstall --force -y dioxus-cli leptosfmt yew-fmt

            - name: Check for upstream releases
              run: cargo run -p scripts --bin upstream
              env:
                  GITHUB_ACTOR: ${{ env.GITHUB_ACTOR }}
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
                  GIT_USER_NAME: rust-for-web[bot]
                  GIT_USER_EMAIL: 191031261+rust-for-web[bot]@users.noreply.github.com
                  RUST_LOG: upstream=info
