name: vlib modules CI

on:
  pull_request:
    paths:
      - 'vlib/**.v'
      - 'vlib/**.md'
      - 'cmd/tools/vdoc/**.v'
      - '**/module_docs_ci.yml'
  push:
    paths:
      - 'vlib/**.v'
      - 'vlib/**.md'
      - 'cmd/tools/vdoc/**.v'
      - '**/module_docs_ci.yml'

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: module_docs-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ !contains(github.ref, 'master')}}

jobs:
  build-module-docs:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
      - name: Build V
        run: make -j4 && ./v symlink
      - name: Install markdown from vpm
        run: v retry -- v install markdown
      - name: Test v doc
        run: ./v test cmd/tools/vdoc/
      - name: Build module documentation
        run: ./v doc -m -f html vlib/
      - name: Deploy docs to vercel
        if: github.event_name == 'push' && github.repository == 'vlang/v' && github.ref == 'refs/heads/master'
        run: npx vercel --confirm --prod --name vmodules --token ${{ secrets.VERCEL_TOKEN }} vlib/_docs/ || true
