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: Generate GitHub App token
              id: app-token
              uses: actions/create-github-app-token@v2
              with:
                  app-id: ${{ secrets.APP_ID }}
                  private-key: ${{ secrets.APP_PRIVATE_KEY }}

            - name: Checkout
              uses: actions/checkout@v5

            - name: Set up Rust toolchain
              uses: actions-rust-lang/setup-rust-toolchain@v1
              with:
                  components: clippy, rustfmt
                  target: wasm32-unknown-unknown

            - 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: rust-for-web[bot]
                  GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
                  GIT_USER_NAME: rust-for-web[bot]
                  GIT_USER_EMAIL: 191031261+rust-for-web[bot]@users.noreply.github.com
                  RUST_LOG: upstream=info
