# Re-fetches the Jitsi SDK and opens a PR to update it if it's different from what's in the repository
name: Update Jitsi
on:
    workflow_dispatch: {}
    schedule:
        - cron: "0 3 * * 0" # 3am every Sunday
permissions: {} # We use ELEMENT_BOT_TOKEN instead
jobs:
    update:
        runs-on: ubuntu-24.04
        steps:
            - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
              with:
                  persist-credentials: false

            - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
            - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
              with:
                  cache: "pnpm"
                  node-version: "lts/*"

            - name: Install Deps
              run: "pnpm install --frozen-lockfile"

            - name: Fetch Jitsi
              working-directory: apps/web
              run: "pnpm vendor:jitsi"

            - name: Create Pull Request
              uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8
              with:
                  token: ${{ secrets.ELEMENT_BOT_TOKEN }}
                  branch: actions/jitsi-update
                  delete-branch: true
                  title: Jitsi Update
                  labels: |
                      T-Task
