name: Update examples

on:
  schedule:
    - cron: "0 0 * * 0"

permissions:
  contents: read

jobs:
  examples:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write

    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          fetch-depth: 0

      - name: Use Node.js
        uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
        with:
          node-version: lts/*
          cache: yarn

      - run: yarn --frozen-lockfile

      - run: yarn link --frozen-lockfile || true

      - run: yarn link webpack --frozen-lockfile

      - run: yarn build:examples

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
        with:
          token: ${{ secrets.PAT }}
          delete-branch: true
          commit-message: |
            docs: update examples
          title: |
            docs: update examples
          body: |
            Update examples.

            This PR was autogenerated.
          branch: update-examples
