name: update-reports

on:
  schedule:
    - cron: "0 23 1 * *"
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-24.04
    permissions: {}
    timeout-minutes: 20
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - name: Checkout files
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
        with:
          persist-credentials: false
          submodules: true

      - uses: ./.github/actions/setup-pnpm
      - run: pnpm license:summary
      - run: pnpm jscpd:summary
      - run: pnpm format
      - run: pnpm deps:graph

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
        with:
          token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
          commit-message: "contents: update reports (license + jscpd + deps graph)"
          title: "contents: update reports (license + jscpd + deps graph)"
          body: |
            This is an update PR of auto generated reports:
            - License summary (library-license.txt)
            - Code duplication analysis (jscpd-summary.txt)
            - Dependency graph (dependency-graph.md)
