name: 📼 VHS
on:
  push:
    paths:
      - 'docs/tapes/*.tape'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  vhs:
    name: Create VHS
    runs-on: ubuntu-22.04
    if: ${{ github.repository == 'wxt-dev/wxt' }}
    permissions:
      contents: write
    steps:
      - name: Checkout
        uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0

      - name: Setup
        uses: ./.github/actions/setup
        with:
          install: false

      # This prevents pnpm dlx from downloading WXT in the video
      - name: Pre-install WXT
        run: |
          pnpm store add wxt@latest
          pnpm dlx wxt@latest --version

      - name: Record VHS
        uses: charmbracelet/vhs-action@59641cdc7fadf3978db65eb8c6937ea2752f4ec3 # v2.1.0
        with:
          path: 'docs/tapes/init-demo.tape'

      - name: Save recorded GIF
        uses: stefanzweifel/git-auto-commit-action@01d77ca6cb089da1360e540865f7d035c95aa199 # v6.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          commit_message: 'docs: Update `wxt init` GIF'
          # https://github.com/charmbracelet/vhs#output
          file_pattern: 'docs/assets/*.gif'
